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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Tue Jun 27 10:25:42 2006 UTC (18 years, 5 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/10, YODA6_3/14, YODA6_3/06, YODA6_3/04, YODA6_3/05, YODA6_3/07, YODA6_3/08, YODA6_3/09
Changes since 6.0: +5 -5 lines
File MIME type: text/plain
Final release for the Traker's routines.

1 kusanagi 5.1 /************************************************************
2     * 20/9/2005 modified by david fedele to read buffer-data
3     * instead raw-data-file
4     **************************************************************
5 kusanagi 1.1 * include needed system headers
6     */
7     #include <stdio.h> /* include standard i/o library */
8     #include <stdlib.h> /* include standard library */
9     #include <string.h> /* include string library */
10     #include <unistd.h> /* include unix standard library */
11     #include <sys/types.h> /* */
12     #include <sys/stat.h> /* */
13     #include <fcntl.h> /* */
14     #include <errno.h> /* error simbol definitions */
15     #include <time.h> /* system time definitions */
16     #include <math.h> /* math library */
17 kusanagi 5.1 /************************************************************
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 kusanagi 1.1
22    
23 kusanagi 5.1 void readsig_(float *sig_buf, int *error,char *buffer, int *len,int *curpos)
24 kusanagi 1.1 {
25     int i;
26 kusanagi 5.1 unsigned int word;
27     unsigned int decimals,units;
28     unsigned int sig_buf_temp[1024];
29 kusanagi 1.1
30    
31     *error=0;
32 kusanagi 5.1 /************************************************************
33     * 20/9/2005 modified by david fedele */
34     /* int nread; */
35    
36     /* /\*** 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 kusanagi 6.1 if( *curpos+1024>*len ) {
60 kusanagi 5.1 printf("readsig: Unexpected end of file \n");
61 kusanagi 1.1 *error=1;
62     return ;
63     }
64 kusanagi 6.1
65     for(i=0; i<1024; i++)
66     getbytes_(&nbytes2,buff,curpos,&sig_buf_temp[i]);
67    
68 kusanagi 5.1 /*****************************************************************/
69 kusanagi 1.1
70    
71     /***interpreta*/
72     for(i=0; i<1024; i++) {
73    
74     word = sig_buf_temp[i];
75     units = ( (word >> 4) & 0x0fff ) ;
76     decimals = (word & 0x000f) ;
77     sig_buf[i] = (float)units + (float)decimals / 16.;
78     // printf("%i %i %i %f \n",i,units,decimals,sig_buf[i]);
79     }
80    
81    
82    
83     // for( i=0; i<1024; i++) printf("%x \n",sig_buf[i]);//???
84    
85     return;
86     }

  ViewVC Help
Powered by ViewVC 1.1.23