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

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

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

revision 1.1 by kusanagi, Tue Jul 6 12:20:23 2004 UTC revision 6.0 by kusanagi, Tue Feb 7 17:11:11 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 readsig_(float *sig_buf, int *error, int *fd) */
20    void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21    
 void readsig_(float *sig_buf, int *error, int *fd)  
22    
23     void readsig_(float *sig_buf, int *error,char *buffer, int *len,int *curpos)
24  {  {
     int nread;  
25      int i;      int i;
26      unsigned short word;      unsigned int word;
27      unsigned short decimals,units;      unsigned int decimals,units;
28      unsigned short sig_buf_temp[1024];      unsigned int sig_buf_temp[1024];
29            
30    
31      *error=0;      *error=0;
32    /************************************************************
33  /*** read the buffer ***/   *     20/9/2005 modified by david fedele                     */
34      nread=read(*fd, sig_buf_temp, 2*1024);   /*    int nread; */
35      if( nread==0 ) {  
36          printf("readsig: Unexpected end of file %d at %d \n",*fd,nread);  /* /\*** read the buffer ***\/ */
37    /*     nread=read(*fd, sig_buf_temp, 2*1024); */
38    /*     if( nread==0 ) { */
39    /*      printf("readsig: Unexpected end of file %d at %d \n",*fd,nread); */
40    /*      *error=1; */
41    /*      return ; */
42    /*     } */
43    /*     if ( nread != 2*1024) { */
44    /*      printf("readsig: Error on reading: nread = %d \n",nread); */
45    /*      *error=-1; */
46    /*      return ;  */
47    /*     } */
48    
49    
50    /* /\*** correct byte ***\/ //endianess... */
51    /*     for(i=0; i<1024; i++) { */
52    /*      word = sig_buf_temp[i]; */
53    /*      sig_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
54    /*     } */
55    
56        int nbytes2=2;
57        char *buff=buffer;
58    
59        for(i=0; i<1024; i++){
60            getbytes_(&nbytes2,buff,curpos,&sig_buf_temp[i]);
61          
62          if( *curpos-1>*len ) {
63            printf("readsig: Unexpected end of file \n");
64          *error=1;          *error=1;
65          return ;          return ;
66          }
67      }      }
68      if ( nread != 2*1024) {  /*****************************************************************/
         printf("readsig: Error on reading: nread = %d \n",nread);  
         *error=-1;  
         return ;  
     }  
   
   
 /*** correct byte ***/ //endianess...  
     for(i=0; i<1024; i++) {  
         word = sig_buf_temp[i];  
         sig_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 );  
     }  
69    
70    
71      /***interpreta*/      /***interpreta*/

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

  ViewVC Help
Powered by ViewVC 1.1.23