/* * 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 */ void readped_(float *ped_buf, int *error, int *fd) { int nread; int i; unsigned short decimals,units; unsigned short word; unsigned short ped_buf_temp[1024]; *error=0; /*** read the buffer ***/ nread=read(*fd, ped_buf_temp, 2*1024); if( nread==0 ) { printf("readped: Unexpected end of file %d at %d \n",*fd,nread); *error=1; return ; } if ( nread != 2*1024) { printf("readped: Error on reading: nread = %d \n",nread); *error=-1; return ; } /*** correct byte ***/ //endianess... for(i=0; i<1024; i++) { word = ped_buf_temp[i]; ped_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); } /***interpreta*/ for(i=0; i<1024; i++) { word = ped_buf_temp[i]; units = ( (word >> 4) & 0x0fff ) ; decimals = (word & 0x000f) ; ped_buf[i] = (float)units + (float)decimals / 16.; // printf("%i %i %i %f \n",i,units,decimals,ped_buf[i]); } // for( i=0; i<1024; i++) printf("%x \n",ped_buf[i]);//??? return; }