/************************************************************ * 20/9/2005 modified by david fedele to read buffer-data * instead raw-data-file ************************************************************** * include needed system headers */ #include /* include standard i/o library */ #include /* include standard library */ #include /* include string library */ #include /* include unix standard library */ #include /* */ #include /* */ #include /* */ #include /* error simbol definitions */ #include /* system time definitions */ #include /* math library */ /************************************************************ * 20/9/2005 modified by david fedele */ /* void readbad_(unsigned short *bad_buf, int *error, int *fd) */ void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value); void readbad_(unsigned short *bad_buf, int *error,char *buffer, int *len,int *curpos) /**************************************************************/ { int i,j,ii,jj; unsigned int word; unsigned int skip; unsigned int bad_buf_temp[64]; *error=0; /************************************************************ * 20/9/2005 modified by david fedele */ /* int nread; */ /* /\*** read the buffer ***\/ */ /* nread=read(*fd, bad_buf_temp, 2*64); */ /* if( nread==0 ) { */ /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */ /* *error=1; */ /* return ; */ /* } */ /* if ( nread != 2*64) { */ /* printf("readbad: Error on reading: nread = %d \n",nread); */ /* *error=-1; */ /* return ; */ /* } */ /* /\*** correct byte ***\/ //endianess... */ /* for(i=0; i<64; i++) { */ /* word = bad_buf_temp[i]; */ /* bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */ /* } */ int nbytes2=2; char *buff=buffer; if( *curpos+(2*64)+2-1>*len ) { printf("readbad: Unexpected end of file \n"); *error=1; return ; } for(i=0; i<64; i++) getbytes_(&nbytes2,buff,curpos,&bad_buf_temp[i]); /*****************************************************************/ for(i=0; i<64; i++) { word = bad_buf_temp[i]; for(j=0; j<16; j++) { jj=15-j; ii=j+i*16; bad_buf[ii] = ( (word >> jj) & 0x0001 ); } } // for( i=0; i<64; i++) printf("%i %x \n",i,bad_buf_temp[i]);//??? */ // printf("\n");//??? */ // for( i=0; i<1024; i++) printf("%i %i \n",i,bad_buf[i]);//??? */ //legge la parola di fine ladder... per saltarla... /************************************************************ * 20/9/2005 modified by david fedele */ /* /\*** read the buffer ***\/ */ /* nread=read(*fd, &skip, 2); */ /* if( nread==0 ) { */ /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */ /* *error=1; */ /* return ; */ /* } */ /* if ( nread != 2) { */ /* printf("readbad: Error on reading: nread = %d \n",nread); */ /* *error=-1; */ /* return ; */ /* } */ /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */ /* /\* *error=0; *\/ */ /* /\* /\\*** read the buffer ***\\/ *\/ */ /* /\* nread=read(*fd, bad_buf, 2*64); *\/ */ /* /\* if( nread==0 ) { *\/ */ /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */ /* /\* *error=1; *\/ */ /* /\* return ; *\/ */ /* /\* } *\/ */ /* /\* if ( nread != 2*64) { *\/ */ /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */ /* /\* *error=-1; *\/ */ /* /\* return ; *\/ */ /* /\* } *\/ */ /* /\* /\\*** correct byte ***\\/ //endianess... *\/ */ /* /\* for(i=0; i<64; i++) { *\/ */ /* /\* word = bad_buf[i]; *\/ */ /* /\* bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); *\/ */ /* /\* } *\/ */ /* /\* //legge la parola di fine ladder... per saltarla... *\/ */ /* /\* /\\*** read the buffer ***\\/ *\/ */ /* /\* nread=read(*fd, &skip, 2); *\/ */ /* /\* if( nread==0 ) { *\/ */ /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */ /* /\* *error=1; *\/ */ /* /\* return ; *\/ */ /* /\* } *\/ */ /* /\* if ( nread != 2) { *\/ */ /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */ /* /\* *error=-1; *\/ */ /* /\* return ; *\/ */ /* /\* } *\/ */ getbytes_(&nbytes2,buff,curpos,&skip); /* if( *curpos-1>*len ) { */ /* printf("readbad: Unexpected end of file \n"); */ /* *error=1; */ /* return ; */ /* } */ /*****************************************************************/ /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */ return; }