/[PAMELA software]/yoda/techmodel/forroutines/anticounter/AC.c
ViewVC logotype

Diff of /yoda/techmodel/forroutines/anticounter/AC.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.9 by kusanagi, Wed Feb 9 22:18:49 2005 UTC revision 3.0 by kusanagi, Fri Mar 4 15:54:11 2005 UTC
# Line 1  Line 1 
1  /*******************************v1.2********************************  /*******************************v1.3********************************
2    
3  Functions to read AC physics data (ACphysics) and AC calibration  Functions to read AC physics data (ACphysics) and AC calibration
4  data (ACcalib).  data (ACcalib).
# Line 7  Author: Petter Hofverberg, petter@partic Line 7  Author: Petter Hofverberg, petter@partic
7  0410 v1.0 alive  0410 v1.0 alive
8  0412 v1.1 fixed problem with found, and changed headers  0412 v1.1 fixed problem with found, and changed headers
9  0502 v1.2 added a crc check  0502 v1.2 added a crc check
10    0502 v1.3 increased buffer size
11    
12  Errors: (returned to the main program as the variable "err")  Errors: (returned to the main program as the variable "err")
13  err=  err=
# Line 24  CRCcheck:  1 - OK, 0 - error Line 25  CRCcheck:  1 - OK, 0 - error
25  #define FALSE 0  #define FALSE 0
26    
27  int i,j,found;  int i,j,found;
28  unsigned short buffer[1000];  unsigned short buffer[8300];
29  unsigned short tmp1,tmp2,check;  unsigned short tmp1,tmp2,check;
30  unsigned char err;  unsigned char err;
31    
# Line 177  unsigned char ACphysics(int length,unsig Line 178  unsigned char ACphysics(int length,unsig
178    found=0;    found=0;
179    check=0;    check=0;
180    int iter=2;    int iter=2;
181    for(i=0;i<1000;i++)    for(i=0;i<8300;i++)
182      buffer[i]=0;      buffer[i]=0;
183    fillphys(0,&buffer[0]);    fillphys(0,&buffer[0]);
184    fillphys(1,&buffer[0]);    fillphys(1,&buffer[0]);
185    
   //point struct-pointer to physicsdata  
   //physicspointer[0]=physicsdata[0];  //card1  
   //physicspointer[1]=physicsdata[1];  //card2  
   //physicspointer=&physicsdata[0];  
   
186    //look for top header ACAC, then unpack data to main card buffer or extra card buffer depending on the subheader    //look for top header ACAC, then unpack data to main card buffer or extra card buffer depending on the subheader
187    //AC11 for main, AC22 for extra    //AC11 for main, AC22 for extra
188    while(found<2 && iter<length)    while(found<2 && iter<length)
# Line 227  unsigned char ACphysics(int length,unsig Line 223  unsigned char ACphysics(int length,unsig
223  }  }
224    
225    
226  unsigned char ACcalib(int length, unsigned char* datapointer, struct calibstruct *calibpointer)  unsigned char ACcalib(int length, unsigned char* datapointer, struct calibstruct* calibpointer)
227  {  {
228    
229    err=0;    err=0;
230    found=0;    found=0;
231    check=0;    check=0;
232    int iter=2;    int iter=2;
233    for(i=0;i<1000;i++)    for(i=0;i<8300;i++)
234      buffer[i]=0;      buffer[i]=0;
235    fillcalib(&buffer[0]);    fillcalib(&buffer[0]);
236    
   //point struct-pointer to calibdata  
   //calibpointer[0]=calibdata[0];  //card1  
   //calibpointer[1]=calibdata[1];  //card2  
   
237    //look for the top header 0xACCA, then the subheaders 0xAC11 and 0xAC22, and unpack the data    //look for the top header 0xACCA, then the subheaders 0xAC11 and 0xAC22, and unpack the data
238    //to each card depending on these.    //to each card depending on these.
239    while(found<1 && iter<length)    while(found<1 && iter<length)
# Line 251  unsigned char ACcalib(int length, unsign Line 243  unsigned char ACcalib(int length, unsign
243                
244        if(tmp1 == 0xACCA && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xACA2 && (err&0x0F)==0x0)))        if(tmp1 == 0xACCA && ((tmp2 == 0xAC11 && (err&0xF0)==0x0) || (tmp2 == 0xACA2 && (err&0x0F)==0x0)))
245          {          {
246            for(i=0;i<8258;i++)            for(i=0;i<8257;i++)
247              {              {
248                buffer[i]=((*datapointer) << 8) | *(datapointer+1);                buffer[i]=((*datapointer) << 8) | *(datapointer+1);
249                if(i<8257)                if(i<8256) //8257
250                  check=crc(check,buffer[i]);                  check=crc(check,buffer[i]);
251                datapointer=datapointer+2;                datapointer=datapointer+2;
252                }                }
# Line 274  unsigned char ACcalib(int length, unsign Line 266  unsigned char ACcalib(int length, unsign
266          datapointer++;          datapointer++;
267          iter=iter+1;}          iter=iter+1;}
268      }      }
269      memcpy(calibpointer,     &calibdata,     sizeof(calibdata));    memcpy(calibpointer,&calibdata,sizeof(calibdata));
270          
271    return err;    return err;
272  }  }
273    

Legend:
Removed from v.2.9  
changed lines
  Added in v.3.0

  ViewVC Help
Powered by ViewVC 1.1.23