/[PAMELA software]/tracker/ground/source/readraw/readped.c
ViewVC logotype

Annotation of /tracker/ground/source/readraw/readped.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Wed Mar 8 15:00:39 2006 UTC (18 years, 9 months ago) by pam-fi
Branch point for: MAIN, trk-ground
File MIME type: text/plain
Initial revision

1 pam-fi 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
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     /************************************************************
18     * 20/9/2005 modified by david fedele */
19     /*void readped_(float *ped_buf, int *error, int *fd)*/
20     void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21    
22    
23     void readped_(float *ped_buf, int *error,char *buffer, int *len,int *curpos)
24     /**************************************************************/
25    
26     {
27    
28     int i;
29     unsigned int decimals,units;
30     unsigned int word;
31     unsigned int ped_buf_temp[1024];
32    
33     *error=0;
34     /************************************************************
35     * 20/9/2005 modified by david fedele */
36     /* int nread; */
37    
38     /* /\*** read the buffer ***\/ */
39     /* nread=read(*fd, ped_buf_temp, 2*1024); */
40     /* if( nread==0 ) { */
41     /* printf("readped: Unexpected end of file %d at %d \n",*fd,nread); */
42     /* *error=1; */
43     /* return ; */
44     /* } */
45     /* if ( nread != 2*1024) { */
46     /* printf("readped: Error on reading: nread = %d \n",nread); */
47     /* *error=-1; */
48     /* return ; */
49     /* } */
50    
51    
52     /* /\*** correct byte ***\/ //endianess... */
53     /* for(i=0; i<1024; i++) { */
54     /* word = ped_buf_temp[i]; */
55     /* ped_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
56     /* } */
57    
58     int nbytes2=2;
59     char *buff=buffer;
60    
61     for(i=0; i<1024; i++){
62     getbytes_(&nbytes2,buff,curpos,&ped_buf_temp[i]);
63    
64     if( *curpos-1>*len ) {
65     printf("readped: Unexpected end of file\n");
66     *error=1;
67     return ;
68     }
69     }
70     /*****************************************************************/
71    
72     /***interpreta*/
73     for(i=0; i<1024; i++) {
74    
75     word = ped_buf_temp[i];
76     units = ( (word >> 4) & 0x0fff ) ;
77     decimals = (word & 0x000f) ;
78     ped_buf[i] = (float)units + (float)decimals / 16.;
79     // printf("%i %i %i %f \n",i,units,decimals,ped_buf[i]);
80     }
81    
82    
83     // for( i=0; i<1024; i++) printf("%x \n",ped_buf[i]);//???
84    
85     return;
86     }

  ViewVC Help
Powered by ViewVC 1.1.23