/[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 3.0 - (hide annotations) (download)
Fri Mar 4 15:54:11 2005 UTC (19 years, 9 months ago) by kusanagi
Branch: MAIN
Changes since 2.0: +0 -0 lines
File MIME type: text/plain
Error proof version.
Implemented all detectors packets plus all the main telemetries packets.
Missing all the Init and Alarm packets.
Disabled CRC control on VarDump, ArrDump, TabDump for CPU debugging needs
(the data formats seems correct even if CRC get wrong)

1 kusanagi 1.1 /*
2     * include needed system headers
3     */
4     #include <stdio.h> /* include standard i/o library */
5     #include <stdlib.h> /* include standard library */
6     #include <string.h> /* include string library */
7     #include <unistd.h> /* include unix standard library */
8     #include <sys/types.h> /* */
9     #include <sys/stat.h> /* */
10     #include <fcntl.h> /* */
11     #include <errno.h> /* error simbol definitions */
12     #include <time.h> /* system time definitions */
13     #include <math.h> /* math library */
14    
15     void readped_(float *ped_buf, int *error, int *fd)
16    
17     {
18     int nread;
19     int i;
20     unsigned short decimals,units;
21     unsigned short word;
22     unsigned short ped_buf_temp[1024];
23    
24    
25     *error=0;
26    
27     /*** read the buffer ***/
28     nread=read(*fd, ped_buf_temp, 2*1024);
29     if( nread==0 ) {
30     printf("readped: Unexpected end of file %d at %d \n",*fd,nread);
31     *error=1;
32     return ;
33     }
34     if ( nread != 2*1024) {
35     printf("readped: Error on reading: nread = %d \n",nread);
36     *error=-1;
37     return ;
38     }
39    
40    
41     /*** correct byte ***/ //endianess...
42     for(i=0; i<1024; i++) {
43     word = ped_buf_temp[i];
44     ped_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 );
45     }
46    
47     /***interpreta*/
48     for(i=0; i<1024; i++) {
49    
50     word = ped_buf_temp[i];
51     units = ( (word >> 4) & 0x0fff ) ;
52     decimals = (word & 0x000f) ;
53     ped_buf[i] = (float)units + (float)decimals / 16.;
54     // printf("%i %i %i %f \n",i,units,decimals,ped_buf[i]);
55     }
56    
57    
58     // for( i=0; i<1024; i++) printf("%x \n",ped_buf[i]);//???
59    
60     return;
61     }

  ViewVC Help
Powered by ViewVC 1.1.23