/[PAMELA software]/yoda/techmodel/forroutines/tracker/readraw/readbad.c
ViewVC logotype

Diff of /yoda/techmodel/forroutines/tracker/readraw/readbad.c

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

revision 2.0 by kusanagi, Tue Sep 21 20:51:20 2004 UTC revision 6.1 by kusanagi, Tue Jun 27 10:25:42 2006 UTC
# Line 1  Line 1 
1  /*  /************************************************************
2    *     20/9/2005 modified by david fedele to read buffer-data
3    *     instead raw-data-file
4    **************************************************************
5   * include needed system headers   * include needed system headers
6   */   */
7  #include <stdio.h>       /* include standard i/o library */  #include <stdio.h>       /* include standard i/o library */
# Line 11  Line 14 
14  #include <errno.h>       /* error simbol definitions */  #include <errno.h>       /* error simbol definitions */
15  #include <time.h>        /* system time definitions */  #include <time.h>        /* system time definitions */
16  #include <math.h>        /* math library */  #include <math.h>        /* math library */
17    /************************************************************
18     *     20/9/2005 modified by david fedele                     */
19    /* void readbad_(unsigned short *bad_buf, int *error, int *fd) */
20    void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21    
22  void readbad_(unsigned short *bad_buf, int *error, int *fd)  void readbad_(unsigned short *bad_buf, int *error,char *buffer, int *len,int *curpos)
23    /**************************************************************/
24  {  {
     int nread;  
25      int i,j,ii,jj;      int i,j,ii,jj;
26      unsigned short word;      unsigned int word;
27      unsigned short skip;      unsigned int skip;
28      unsigned short bad_buf_temp[64];      unsigned int bad_buf_temp[64];
29    
30      *error=0;      *error=0;
31    /************************************************************
32     *     20/9/2005 modified by david fedele                     */
33     /*    int nread; */
34    
35  /*** read the buffer ***/  /* /\*** read the buffer ***\/ */
36      nread=read(*fd, bad_buf_temp, 2*64);  /*     nread=read(*fd, bad_buf_temp, 2*64); */
37      if( nread==0 ) {  /*     if( nread==0 ) { */
38          printf("readbad: Unexpected end of file %d at %d \n",*fd,nread);  /*      printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
39          *error=1;  /*      *error=1; */
40          return ;  /*      return ; */
41      }  /*     } */
42      if ( nread != 2*64) {  /*     if ( nread != 2*64) { */
43          printf("readbad: Error on reading: nread = %d \n",nread);  /*      printf("readbad: Error on reading: nread = %d \n",nread); */
44          *error=-1;  /*      *error=-1; */
45          return ;  /*      return ;  */
46      }  /*     } */
47    
48    
49  /*** correct byte ***/ //endianess...  /* /\*** correct byte ***\/ //endianess... */
50      for(i=0; i<64; i++) {  /*     for(i=0; i<64; i++) { */
51          word = bad_buf_temp[i];  /*      word = bad_buf_temp[i]; */
52          bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 );  /*      bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
53    /*     } */
54    
55    
56        int nbytes2=2;
57        char *buff=buffer;
58        
59        if( *curpos+64+2>*len ) {
60            printf("readbad: Unexpected end of file \n");
61            *error=1;
62            return ;
63      }      }
64    
65        for(i=0; i<64; i++)
66            getbytes_(&nbytes2,buff,curpos,&bad_buf_temp[i]);
67        
68    /*****************************************************************/
69    
70    
71      for(i=0; i<64; i++) {      for(i=0; i<64; i++) {
# Line 81  void readbad_(unsigned short *bad_buf, i Line 104  void readbad_(unsigned short *bad_buf, i
104    
105    
106  //legge la parola di fine ladder... per saltarla...  //legge la parola di fine ladder... per saltarla...
107    /************************************************************
108  /*** read the buffer ***/   *     20/9/2005 modified by david fedele                     */
     nread=read(*fd, &skip, 2);  
     if( nread==0 ) {  
         printf("readbad: Unexpected end of file %d at %d \n",*fd,nread);  
         *error=1;  
         return ;  
     }  
     if ( nread != 2) {  
         printf("readbad: Error on reading: nread = %d \n",nread);  
         *error=-1;  
         return ;  
     }  
   
   
   
   
 //    for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//???  
   
   
   
   
 /*     *error=0; */  
   
109  /* /\*** read the buffer ***\/ */  /* /\*** read the buffer ***\/ */
110  /*     nread=read(*fd, bad_buf, 2*64); */  /*     nread=read(*fd, &skip, 2); */
111  /*     if( nread==0 ) { */  /*     if( nread==0 ) { */
112  /*      printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */  /*      printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
113  /*      *error=1; */  /*      *error=1; */
114  /*      return ; */  /*      return ; */
115  /*     } */  /*     } */
116  /*     if ( nread != 2*64) { */  /*     if ( nread != 2) { */
117  /*      printf("readbad: Error on reading: nread = %d \n",nread); */  /*      printf("readbad: Error on reading: nread = %d \n",nread); */
118  /*      *error=-1; */  /*      *error=-1; */
119  /*      return ;  */  /*      return ;  */
120  /*     } */  /*     } */
121    
122    
 /* /\*** correct byte ***\/ //endianess... */  
 /*     for(i=0; i<64; i++) { */  
 /*      word = bad_buf[i]; */  
 /*      bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */  
 /*     } */  
123    
 /* //legge la parola di fine ladder... per saltarla... */  
124    
125  /* /\*** read the buffer ***\/ */  /* //    for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
126  /*     nread=read(*fd, &skip, 2); */  
127  /*     if( nread==0 ) { */  
128  /*      printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */  
 /*      *error=1; */  
 /*      return ; */  
 /*     } */  
 /*     if ( nread != 2) { */  
 /*      printf("readbad: Error on reading: nread = %d \n",nread); */  
 /*      *error=-1; */  
 /*      return ;  */  
 /*     } */  
129    
130    /* /\*     *error=0; *\/ */
131    
132    /* /\* /\\*** read the buffer ***\\/ *\/ */
133    /* /\*     nread=read(*fd, bad_buf, 2*64); *\/ */
134    /* /\*     if( nread==0 ) { *\/ */
135    /* /\*  printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
136    /* /\*  *error=1; *\/ */
137    /* /\*  return ; *\/ */
138    /* /\*     } *\/ */
139    /* /\*     if ( nread != 2*64) { *\/ */
140    /* /\*  printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
141    /* /\*  *error=-1; *\/ */
142    /* /\*          return ;  *\/ */
143    /* /\*     } *\/ */
144    
145    
146    /* /\* /\\*** correct byte ***\\/ //endianess... *\/ */
147    /* /\*     for(i=0; i<64; i++) { *\/ */
148    /* /\*  word = bad_buf[i]; *\/ */
149    /* /\*  bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); *\/ */
150    /* /\*     } *\/ */
151    
152    /* /\* //legge la parola di fine ladder... per saltarla... *\/ */
153    
154    /* /\* /\\*** read the buffer ***\\/ *\/ */
155    /* /\*     nread=read(*fd, &skip, 2); *\/ */
156    /* /\*     if( nread==0 ) { *\/ */
157    /* /\*  printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
158    /* /\*  *error=1; *\/ */
159    /* /\*  return ; *\/ */
160    /* /\*     } *\/ */
161    /* /\*     if ( nread != 2) { *\/ */
162    /* /\*  printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
163    /* /\*  *error=-1; *\/ */
164    /* /\*          return ;  *\/ */
165    /* /\*     } *\/ */
166    
167      
168        getbytes_(&nbytes2,buff,curpos,&skip);
169        
170       /*  if( *curpos-1>*len ) { */
171    /*       printf("readbad: Unexpected end of file \n"); */
172    /*       *error=1; */
173    /*       return ; */
174    /*     } */
175    /*****************************************************************/
176    
177    
178    

Legend:
Removed from v.2.0  
changed lines
  Added in v.6.1

  ViewVC Help
Powered by ViewVC 1.1.23