FSUDAQ/decode.C
2022-10-07 18:52:15 -04:00

40 lines
970 B
C

#include "ClassData.h"
void decode() {
FILE * haha = fopen("ExpName_run000_323_000.fsu", "r");
fseek(haha, 0L, SEEK_END);
size_t inFileSize = ftell(haha);
printf("file size : %d Byte\n", (int) inFileSize);
fclose(haha);
Data * data = new Data();
data->DPPType = V1730_DPP_PHA_CODE;
haha = fopen("ExpName_run000_323_000.fsu", "r");
printf("pos : %d \n", (int) ftell(haha));
do{
unsigned int word[1]; /// 4 bytes
size_t dump = fread(word, 4, 1, haha);
fseek(haha, -4, SEEK_CUR);
unsigned int aggSize = (word[0] & 0x0FFFFFFF) * 4; ///byte
short header = ((word[0] >> 28 ) & 0xF);
if( header != 10 ) break;
printf("-------- %7d word = %d bytes\n", aggSize/4, aggSize);
char * buffer = new char[aggSize];
dump = fread(buffer, aggSize, 1, haha);
data->DecodeBuffer(buffer, aggSize, 0, 2);
if( ftell(haha) >= 12046*10 ) break;
}while(!feof(haha) );
fclose(haha);
}