/[PAMELA software]/chewbacca/PamOffLineSW/forroutines/tracker/readraw/readbad.c
ViewVC logotype

Contents of /chewbacca/PamOffLineSW/forroutines/tracker/readraw/readbad.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Sep 23 07:20:17 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: v0r00, MAIN
CVS Tags: v1r02, v1r00, v1r01, start, v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Imported sources, 23/09/2008

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 readbad_(unsigned short *bad_buf, int *error, int *fd) */
20 void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21
22 void readbad_(unsigned short *bad_buf, int *error,char *buffer, int *len,int *curpos)
23 /**************************************************************/
24 {
25 int i,j,ii,jj;
26 unsigned int word;
27 unsigned int skip;
28 unsigned int bad_buf_temp[64];
29
30 *error=0;
31 /************************************************************
32 * 20/9/2005 modified by david fedele */
33 /* int nread; */
34
35 /* /\*** read the buffer ***\/ */
36 /* nread=read(*fd, bad_buf_temp, 2*64); */
37 /* if( nread==0 ) { */
38 /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
39 /* *error=1; */
40 /* return ; */
41 /* } */
42 /* if ( nread != 2*64) { */
43 /* printf("readbad: Error on reading: nread = %d \n",nread); */
44 /* *error=-1; */
45 /* return ; */
46 /* } */
47
48
49 /* /\*** correct byte ***\/ //endianess... */
50 /* for(i=0; i<64; i++) { */
51 /* word = bad_buf_temp[i]; */
52 /* bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
53 /* } */
54
55
56 int nbytes2=2;
57 char *buff=buffer;
58
59 if( *curpos+(2*64)+2-1>*len ) {
60 printf("readbad: Unexpected end of file \n");
61 *error=1;
62 return ;
63 }
64
65 for(i=0; i<64; i++)
66 getbytes_(&nbytes2,buff,curpos,&bad_buf_temp[i]);
67
68 /*****************************************************************/
69
70
71 for(i=0; i<64; i++) {
72
73 word = bad_buf_temp[i];
74
75 for(j=0; j<16; j++) {
76
77 jj=15-j;
78 ii=j+i*16;
79
80 bad_buf[ii] = ( (word >> jj) & 0x0001 );
81
82
83
84
85 }
86 }
87
88
89 // for( i=0; i<64; i++) printf("%i %x \n",i,bad_buf_temp[i]);//??? */
90
91 // printf("\n");//??? */
92
93 // for( i=0; i<1024; i++) printf("%i %i \n",i,bad_buf[i]);//??? */
94
95
96
97
98
99
100
101
102
103
104
105
106 //legge la parola di fine ladder... per saltarla...
107 /************************************************************
108 * 20/9/2005 modified by david fedele */
109 /* /\*** read the buffer ***\/ */
110 /* nread=read(*fd, &skip, 2); */
111 /* if( nread==0 ) { */
112 /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
113 /* *error=1; */
114 /* return ; */
115 /* } */
116 /* if ( nread != 2) { */
117 /* printf("readbad: Error on reading: nread = %d \n",nread); */
118 /* *error=-1; */
119 /* return ; */
120 /* } */
121
122
123
124
125 /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
126
127
128
129
130 /* /\* *error=0; *\/ */
131
132 /* /\* /\\*** read the buffer ***\\/ *\/ */
133 /* /\* nread=read(*fd, bad_buf, 2*64); *\/ */
134 /* /\* if( nread==0 ) { *\/ */
135 /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
136 /* /\* *error=1; *\/ */
137 /* /\* return ; *\/ */
138 /* /\* } *\/ */
139 /* /\* if ( nread != 2*64) { *\/ */
140 /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
141 /* /\* *error=-1; *\/ */
142 /* /\* return ; *\/ */
143 /* /\* } *\/ */
144
145
146 /* /\* /\\*** correct byte ***\\/ //endianess... *\/ */
147 /* /\* for(i=0; i<64; i++) { *\/ */
148 /* /\* word = bad_buf[i]; *\/ */
149 /* /\* bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); *\/ */
150 /* /\* } *\/ */
151
152 /* /\* //legge la parola di fine ladder... per saltarla... *\/ */
153
154 /* /\* /\\*** read the buffer ***\\/ *\/ */
155 /* /\* nread=read(*fd, &skip, 2); *\/ */
156 /* /\* if( nread==0 ) { *\/ */
157 /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
158 /* /\* *error=1; *\/ */
159 /* /\* return ; *\/ */
160 /* /\* } *\/ */
161 /* /\* if ( nread != 2) { *\/ */
162 /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
163 /* /\* *error=-1; *\/ */
164 /* /\* return ; *\/ */
165 /* /\* } *\/ */
166
167
168 getbytes_(&nbytes2,buff,curpos,&skip);
169
170 /* if( *curpos-1>*len ) { */
171 /* printf("readbad: Unexpected end of file \n"); */
172 /* *error=1; */
173 /* return ; */
174 /* } */
175 /*****************************************************************/
176
177
178
179 /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
180
181 return;
182 }

  ViewVC Help
Powered by ViewVC 1.1.23