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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.3 - (hide annotations) (download)
Thu Nov 2 12:20:08 2006 UTC (18 years, 1 month ago) by pam-fi
Branch: MAIN
CVS Tags: YODA6_3/19, YODA6_3/18, YODA6_3/17, YODA6_3/16, YODA6_3/20, HEAD
Changes since 6.2: +1 -1 lines
File MIME type: text/plain
bug fixed in the control of the lenght buffer to read

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 readped_(float *ped_buf, int *error, int *fd)*/
20     void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21 kusanagi 1.1
22 kusanagi 5.1
23     void readped_(float *ped_buf, int *error,char *buffer, int *len,int *curpos)
24     /**************************************************************/
25 kusanagi 1.1
26     {
27 kusanagi 5.1
28 kusanagi 1.1 int i;
29 kusanagi 5.1 unsigned int decimals,units;
30     unsigned int word;
31     unsigned int ped_buf_temp[1024];
32 kusanagi 1.1
33 kusanagi 5.1 *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 kusanagi 6.1
61 pam-fi 6.3 if( *curpos+(2*1024)-1>*len ) {
62 kusanagi 5.1 printf("readped: Unexpected end of file\n");
63 kusanagi 1.1 *error=1;
64     return ;
65     }
66 kusanagi 6.1
67     for(i=0; i<1024; i++)
68     getbytes_(&nbytes2,buff,curpos,&ped_buf_temp[i]);
69    
70    
71 kusanagi 5.1 /*****************************************************************/
72 kusanagi 1.1
73     /***interpreta*/
74     for(i=0; i<1024; i++) {
75    
76     word = ped_buf_temp[i];
77     units = ( (word >> 4) & 0x0fff ) ;
78     decimals = (word & 0x000f) ;
79     ped_buf[i] = (float)units + (float)decimals / 16.;
80     // printf("%i %i %i %f \n",i,units,decimals,ped_buf[i]);
81     }
82    
83    
84     // for( i=0; i<1024; i++) printf("%x \n",ped_buf[i]);//???
85    
86     return;
87     }

  ViewVC Help
Powered by ViewVC 1.1.23