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

Contents of /yoda/techmodel/forroutines/tracker/readraw/readbad.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.0 - (show 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 /*
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 readbad_(unsigned short *bad_buf, int *error, int *fd)
16
17 {
18 int nread;
19 int i,j,ii,jj;
20 unsigned short word;
21 unsigned short skip;
22 unsigned short bad_buf_temp[64];
23
24 *error=0;
25
26 /*** read the buffer ***/
27 nread=read(*fd, bad_buf_temp, 2*64);
28 if( nread==0 ) {
29 printf("readbad: Unexpected end of file %d at %d \n",*fd,nread);
30 *error=1;
31 return ;
32 }
33 if ( nread != 2*64) {
34 printf("readbad: Error on reading: nread = %d \n",nread);
35 *error=-1;
36 return ;
37 }
38
39
40 /*** correct byte ***/ //endianess...
41 for(i=0; i<64; i++) {
42 word = bad_buf_temp[i];
43 bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 );
44 }
45
46
47
48 for(i=0; i<64; i++) {
49
50 word = bad_buf_temp[i];
51
52 for(j=0; j<16; j++) {
53
54 jj=15-j;
55 ii=j+i*16;
56
57 bad_buf[ii] = ( (word >> jj) & 0x0001 );
58
59
60
61
62 }
63 }
64
65
66 // for( i=0; i<64; i++) printf("%i %x \n",i,bad_buf_temp[i]);//??? */
67
68 // printf("\n");//??? */
69
70 // for( i=0; i<1024; i++) printf("%i %i \n",i,bad_buf[i]);//??? */
71
72
73
74
75
76
77
78
79
80
81
82
83 //legge la parola di fine ladder... per saltarla...
84
85 /*** read the buffer ***/
86 nread=read(*fd, &skip, 2);
87 if( nread==0 ) {
88 printf("readbad: Unexpected end of file %d at %d \n",*fd,nread);
89 *error=1;
90 return ;
91 }
92 if ( nread != 2) {
93 printf("readbad: Error on reading: nread = %d \n",nread);
94 *error=-1;
95 return ;
96 }
97
98
99
100
101 // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//???
102
103
104
105
106 /* *error=0; */
107
108 /* /\*** read the buffer ***\/ */
109 /* nread=read(*fd, bad_buf, 2*64); */
110 /* if( nread==0 ) { */
111 /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
112 /* *error=1; */
113 /* return ; */
114 /* } */
115 /* if ( nread != 2*64) { */
116 /* printf("readbad: Error on reading: nread = %d \n",nread); */
117 /* *error=-1; */
118 /* return ; */
119 /* } */
120
121
122 /* /\*** correct byte ***\/ //endianess... */
123 /* for(i=0; i<64; i++) { */
124 /* word = bad_buf[i]; */
125 /* bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
126 /* } */
127
128 /* //legge la parola di fine ladder... per saltarla... */
129
130 /* /\*** read the buffer ***\/ */
131 /* nread=read(*fd, &skip, 2); */
132 /* if( nread==0 ) { */
133 /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
134 /* *error=1; */
135 /* return ; */
136 /* } */
137 /* if ( nread != 2) { */
138 /* printf("readbad: Error on reading: nread = %d \n",nread); */
139 /* *error=-1; */
140 /* return ; */
141 /* } */
142
143
144
145
146 /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
147
148 return;
149 }

  ViewVC Help
Powered by ViewVC 1.1.23