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

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

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

revision 1.1 by kusanagi, Thu Jul 8 12:48:23 2004 UTC revision 1.2 by kusanagi, Sat Jul 17 20:03:42 2004 UTC
# Line 2  Line 2 
2  #include "ACcalib.h"  #include "ACcalib.h"
3    
4    
5  int ACcalib(unsigned short* datapointer, struct datastruct* calibpointer)  int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer){
6  {  
7    struct datastruct calibdata;
8    
9    //pointer to struct
10    struct datastruct *calibpointer;
11    
12    int fd,i,j,err,found;
13    unsigned short buffer[10000];
14    unsigned short tmp1,tmp2;
15    
16    
17      int iter=2;
18    
19    //point struc-pointer to calibdata    //point struc-pointer to calibdata
20    *calibpointer=calibdata;      *calibpointer=calibdata;  
21    
22    //look for header 0xACCA    //look for header 0xACCA
23    while(found==0)    while(found==0 && iter<length)
24      {      {
25        tmp1=*datapointer;        tmp1=*datapointer;
26        tmp2=*(datapointer+1);        tmp2=*(datapointer+1);
# Line 23  int ACcalib(unsigned short* datapointer, Line 34  int ACcalib(unsigned short* datapointer,
34              }              }
35            tmp1=0x0000;            tmp1=0x0000;
36          }          }
37        if((tmp1&0x00FF) + (tmp2&0xFF00)==0xACCA)        else if((tmp1&0x00FF) + (tmp2&0xFF00)==0xACCA)
38          {          {
39            found=1;            found=1;
40            for(i=0;i<8256;i++)            for(i=0;i<8256;i++)
# Line 34  int ACcalib(unsigned short* datapointer, Line 45  int ACcalib(unsigned short* datapointer,
45                tmp2=*(datapointer+1);                tmp2=*(datapointer+1);
46              }              }
47          }          }
48          else{
49        datapointer++;        datapointer++;
50          iter=iter+2;}
51    
52      }      }
53    
54    //check tail. CHANGE!    //check errors
55    if(buffer[8253]==0xAC22)    if(iter>=length)
56        err=2;
57      else if(buffer[8254]==0x22AC)
58      err=0;      err=0;
59    else    else
60      err=1;      err=1;
# Line 58  int ACcalib(unsigned short* datapointer, Line 73  int ACcalib(unsigned short* datapointer,
73    calibdata.iCRC=buffer[8253];    calibdata.iCRC=buffer[8253];
74    calibdata.tail=buffer[8254];    calibdata.tail=buffer[8254];
75    calibdata.CRC=buffer[8255];    calibdata.CRC=buffer[8255];
76      
77    /*    /*
78    //debug    //debug
79    printf("header: %hx\n",calibdata.header);    printf("header: %hx\n",calibdata.header);
# Line 79  int ACcalib(unsigned short* datapointer, Line 94  int ACcalib(unsigned short* datapointer,
94    
95    return err;    return err;
96  }  }
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23