/[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.7.2.1 by kusanagi, Fri Mar 4 14:13:52 2005 UTC revision 2.9 by kusanagi, Wed Feb 9 22:18:49 2005 UTC
# Line 1  Line 1 
1  /*******************************v1.3********************************  /*******************************v1.2********************************
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
 0502 v1.3 increased buffer size  
10    
11  Errors: (returned to the main program as the variable "err")  Errors: (returned to the main program as the variable "err")
12  err=  err=
# Line 25  CRCcheck:  1 - OK, 0 - error Line 24  CRCcheck:  1 - OK, 0 - error
24  #define FALSE 0  #define FALSE 0
25    
26  int i,j,found;  int i,j,found;
27  unsigned short buffer[8300];  unsigned short buffer[1000];
28  unsigned short tmp1,tmp2,check;  unsigned short tmp1,tmp2,check;
29  unsigned char err;  unsigned char err;
30    
# Line 178  unsigned char ACphysics(int length,unsig Line 177  unsigned char ACphysics(int length,unsig
177    found=0;    found=0;
178    check=0;    check=0;
179    int iter=2;    int iter=2;
180    for(i=0;i<8300;i++)    for(i=0;i<1000;i++)
181      buffer[i]=0;      buffer[i]=0;
182    fillphys(0,&buffer[0]);    fillphys(0,&buffer[0]);
183    fillphys(1,&buffer[0]);    fillphys(1,&buffer[0]);
184    
185      //point struct-pointer to physicsdata
186      //physicspointer[0]=physicsdata[0];  //card1
187      //physicspointer[1]=physicsdata[1];  //card2
188      //physicspointer=&physicsdata[0];
189    
190    //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
191    //AC11 for main, AC22 for extra    //AC11 for main, AC22 for extra
192    while(found<2 && iter<length)    while(found<2 && iter<length)
# Line 223  unsigned char ACphysics(int length,unsig Line 227  unsigned char ACphysics(int length,unsig
227  }  }
228    
229    
230  unsigned char ACcalib(int length, unsigned char* datapointer, struct calibstruct* calibpointer)  unsigned char ACcalib(int length, unsigned char* datapointer, struct calibstruct *calibpointer)
231  {  {
232    
233    err=0;    err=0;
234    found=0;    found=0;
235    check=0;    check=0;
236    int iter=2;    int iter=2;
237    for(i=0;i<8300;i++)    for(i=0;i<1000;i++)
238      buffer[i]=0;      buffer[i]=0;
239    fillcalib(&buffer[0]);    fillcalib(&buffer[0]);
240    
241      //point struct-pointer to calibdata
242      //calibpointer[0]=calibdata[0];  //card1
243      //calibpointer[1]=calibdata[1];  //card2
244    
245    //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
246    //to each card depending on these.    //to each card depending on these.
247    while(found<1 && iter<length)    while(found<1 && iter<length)
# Line 243  unsigned char ACcalib(int length, unsign Line 251  unsigned char ACcalib(int length, unsign
251                
252        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)))
253          {          {
254            for(i=0;i<8257;i++)            for(i=0;i<8258;i++)
255              {              {
256                buffer[i]=((*datapointer) << 8) | *(datapointer+1);                buffer[i]=((*datapointer) << 8) | *(datapointer+1);
257                if(i<8256) //8257                if(i<8257)
258                  check=crc(check,buffer[i]);                  check=crc(check,buffer[i]);
259                datapointer=datapointer+2;                datapointer=datapointer+2;
260                }                }
# Line 266  unsigned char ACcalib(int length, unsign Line 274  unsigned char ACcalib(int length, unsign
274          datapointer++;          datapointer++;
275          iter=iter+1;}          iter=iter+1;}
276      }      }
277    memcpy(calibpointer,&calibdata,sizeof(calibdata));      memcpy(calibpointer,     &calibdata,     sizeof(calibdata));
278          
279    return err;    return err;
280  }  }
281    

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

  ViewVC Help
Powered by ViewVC 1.1.23