⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datachk.c

📁 实现ipvlbi数据记录
💻 C
字号:
/**************************************************************//*                                                            *//*   Program Name :  datachk                                  *//*                                                            *//*      Version:  0.0   2001-08-17                            *//*                2.10  2002-06-04                            *//*                2.11  2002-10-21  to allow extended file    *//*                                                            *//*                                                            *//*      Data Check for PC-VSSP(IP-VLBI) board                 *//*                                                            *//*                                                            *//*      Copyright (c) 2002 T.Kondo/CRL All Right Reserved     *//*                                                            *//**************************************************************//*       巊梡朄  datachk [file_name [mode]]                  偙偙偱 file_name -- 僨乕僞僼傽僀儖柤                                       柍巜掕偺帪                                       tds.data*/#ifndef WIN32#include <unistd.h>#endif#include <stdio.h>#include <errno.h>#include <fcntl.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <sys/stat.h>#ifdef linux#include <sys/time.h>#else#include <time.h>#endif#include "libipvlbi.h"  // IP-VLBI梡娭悢孮(by T.Kondo)void chkfilen(char* fname){	   unsigned char bit64[8];       unsigned char ibuf[5000];	   int nbyte=5000;       int i,iok,spatn,smplbit,numch,hh,mm,ss;	   long int seconds,numb,npos, secold, tflag, nkai;       long int bitsec,bitint;	   int sfreq;       FILE *stream;       int bytesread, rbytes;       int f_c;       char cbuf[10], fname2[80];       double dbytes;	   numb=0;	   npos=0;       nkai=0;       tflag=0;       f_c=0;       dbytes=0.0;       printf("FILE : %s\n",fname);       if( (stream  = fopen( fname, "rb" )) == NULL ) {           printf("File Open Error! \n");		   goto exitend2;       }	       printf("FMT A/D CH  f(kHz)  TIME   seconds   # of bits\n");       bytesread = fread( ibuf, sizeof( char ), nbyte, stream );       dbytes+=(double)bytesread;        if( ferror( stream ) || bytesread==0 ) {           printf("File EOF or Read Error!\n");		   goto exitend;       }       for (i=0; i <8 ; i++){		  bit64[i]=ibuf[i];       }       rbytes=bytesread;loop1:       headerchkn(bit64,&iok,&spatn,&smplbit,&sfreq,&numch,&seconds,      		         &hh,&mm,&ss);       if (iok == 0) {  // sync detection           if (numb >= 8 ){              bitint=(numb-8)*8;              bitsec=sfreq*1000*smplbit*numch;              printf("  %d",bitint);              if (bitint != bitsec){                  printf("NG ");                   if(tflag ==0){                     printf("Warning! (# of bits Error)\n");                   } else {                     printf("Warning! (TIME DISCON and Bits error!)\n");                  }               } else {                  if(tflag==0){                     printf("  \n");                   } else {                     printf(" Warning! (TIME DISCON)\n");                  }               }           }           if(nkai >0 && seconds-secold !=1){                printf("New %2d  %2d   %4d %02d:%02d:%02d %6dNG",                       smplbit,numch, sfreq,hh,mm,ss,seconds);                tflag=1;           } else {                printf("New %2d  %2d   %4d %02d:%02d:%02d %6d  ",                       smplbit,numch, sfreq,hh,mm,ss,seconds);                tflag=0;           }           secold=seconds;           //nkai++;           numb=0;       }       numb++;       npos++;       if (npos >= rbytes){		    npos=0;            rbytes=bytesread;       }       for (i=0; i <7 ; i++){		    bit64[i]=bit64[i+1];       }            if (npos+7 == rbytes){  // next record read            //printf("Next Record Read!\n"); //debug            bytesread = fread( ibuf, sizeof( char ), nbyte, stream );            dbytes+=(double)bytesread;            if (bytesread ==0 ) {// EOF	            i=fclose( stream ) ;			    f_c++;			    // continuous file name creation     XXXX.datN   where N=1,2,3......			    strcpy(fname2,fname);			    sprintf(cbuf,"%d\0",f_c);			    strcat(fname2,cbuf);                /* file open */                if( (stream  = fopen( fname2, "rb" )) == NULL ){                    // file not found		            goto exitend2;                }				    printf("\n continuous file (%s) opened!\n",fname2);                  printf("                                   ");                  bytesread = fread( ibuf, sizeof( char ), nbyte, stream );                dbytes+=(double)bytesread;            }            if( ferror( stream )  ) {			    printf("File Read Error!\n");			    goto exitend;            }       }       if (npos+7 < rbytes ){            bit64[7]=ibuf[npos+7];       } else {            bit64[7]=ibuf[npos+7-rbytes];       }       goto loop1;	 exitend:	    i=fclose( stream ) ;        printf("\n"); exitend2:;        printf("\n");        printf("%f bytes read\n",dbytes); }int main(int argc, char *argv[]){    char fname[60];	char* dflt_fname="tds.data";    if (argc>=2){       strcpy(fname,*(argv+1));    } else {       strcpy(fname,dflt_fname);	}    printf("**** datachk  Ver 2.11 (2002-10-21) ****\n");    chkfilen(fname);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -