#define _CRT_SECURE_NO_WARNINGS
#define FILENAME "DataOutput_XWR14xx.bin"
#define RECORDSTXT "records.txt"
void appendTxtLine(char* str) {
file = fopen("records.txt", "a");
fprintf(file, "%s\n", str);
typedef struct MmwDemo_output_message_tl_t
} MmwDemo_output_message_tl;
MmwDemo_output_message_tl TLV_head, TLV_head1;
typedef struct VitalSignsDemo_OutputStats_t
uint16_t rangeBinIndexMax;
uint16_t rangeBinIndexPhase;
uint32_t processingCyclesOut;
uint16_t rangeBinStartIndex;
uint16_t rangeBinEndIndex;
float unwrapPhasePeak_mm;
float outputFilterBreathOut;
float outputFilterHeartOut;
float heartRateEst_FFT_4Hz;
float heartRateEst_xCorr;
float heartRateEst_peakCount_filtered;
float breathingRateEst_FFT;
float breathingRateEst_xCorr;
float breathingRateEst_peakCount;
float confidenceMetricBreathOut;
float confidenceMetricBreathOut_xCorr;
float confidenceMetricHeartOut;
float confidenceMetricHeartOut_4Hz;
float confidenceMetricHeartOut_xCorr;
float sumEnergyBreathWfm;
float motionDetectedFlag;
float breathingRateEst_harmonicEnergy;
float heartRateEst_harmonicEnergy;
} VitalSignsDemo_OutputStats;
VitalSignsDemo_OutputStats outputStats;
void printOutputStats() {
printf("\nVitalSignsDemo_OutputStats:\n");
printf("rangeBinIndexMax = %hd\n", outputStats.rangeBinIndexMax);
printf("rangeBinIndexPhase = %hd\n", outputStats.rangeBinIndexPhase);
printf("maxVal = %.2f\n", outputStats.maxVal);
printf("processingCyclesOut = %d\n", outputStats.processingCyclesOut);
printf("rangeBinStartIndex = %hd\n", outputStats.rangeBinStartIndex);
printf("rangeBinEndIndex = %hd\n", outputStats.rangeBinEndIndex);
printf("unwrapPhasePeak_mm = %.2f\n", outputStats.unwrapPhasePeak_mm);
printf("outputFilterBreathOut = %.2f\n", outputStats.outputFilterBreathOut);
printf("outputFilterHeartOut = %.2f\n", outputStats.outputFilterHeartOut);
printf("heartRateEst_FFT = %.2f\n", outputStats.heartRateEst_FFT);
printf("heartRateEst_FFT_4Hz = %.2f\n", outputStats.heartRateEst_FFT_4Hz);
printf("heartRateEst_xCorr = %.2f\n", outputStats.heartRateEst_xCorr);
printf("heartRateEst_peakCount_filtered = %.2f\n", outputStats.heartRateEst_peakCount_filtered);
printf("breathingRateEst_FFT = %.2f\n", outputStats.breathingRateEst_FFT);
printf("breathingRateEst_xCorr = %.2f\n", outputStats.breathingRateEst_xCorr);
printf("breathingRateEst_peakCount = %.2f\n", outputStats.breathingRateEst_peakCount);
printf("confidenceMetricBreathOut = %.2f\n", outputStats.confidenceMetricBreathOut);
printf("confidenceMetricBreathOut_xCorr = %.2f\n", outputStats.confidenceMetricBreathOut_xCorr);
printf("confidenceMetricHeartOut = %.2f\n", outputStats.confidenceMetricHeartOut);
printf("confidenceMetricHeartOut_4Hz = %.2f\n", outputStats.confidenceMetricHeartOut_4Hz);
printf("confidenceMetricHeartOut_xCorr = %.2f\n", outputStats.confidenceMetricHeartOut_xCorr);
printf("sumEnergyBreathWfm = %.2f\n", outputStats.sumEnergyBreathWfm);
printf("sumEnergyHeartWfm = %.2f\n", outputStats.sumEnergyHeartWfm);
printf("motionDetectedFlag = %.2f\n", outputStats.motionDetectedFlag);
printf("breathingRateEst_harmonicEnergy = %.2f\n", outputStats.breathingRateEst_harmonicEnergy);
printf("heartRateEst_harmonicEnergy = %.2f\n", outputStats.heartRateEst_harmonicEnergy);
printf("reserved7 = %.2f\n", outputStats.reserved7);
printf("reserved8 = %.2f\n", outputStats.reserved8);
printf("reserved9 = %.2f\n", outputStats.reserved9);
printf("reserved10 = %.2f\n", outputStats.reserved10);
printf("reserved11 = %.2f\n", outputStats.reserved11);
printf("reserved12 = %.2f\n", outputStats.reserved12);
printf("reserved13 = %.2f\n", outputStats.reserved13);
printf("reserved14 = %.2f\n", outputStats.reserved14);
sprintf(buf, "\nVitalSignsDemo_OutputStats:");
sprintf(buf, "rangeBinIndexMax = %hd", outputStats.rangeBinIndexMax);
sprintf(buf, "rangeBinIndexPhase = %hd", outputStats.rangeBinIndexPhase);
sprintf(buf, "maxVal = %.2f", outputStats.maxVal);
sprintf(buf, "processingCyclesOut = %d", outputStats.processingCyclesOut);
sprintf(buf, "rangeBinStartIndex = %hd", outputStats.rangeBinStartIndex);
sprintf(buf, "rangeBinEndIndex = %hd", outputStats.rangeBinEndIndex);
sprintf(buf, "unwrapPhasePeak_mm = %.2f", outputStats.unwrapPhasePeak_mm);
sprintf(buf, "outputFilterBreathOut = %.2f", outputStats.outputFilterBreathOut);
sprintf(buf, "outputFilterHeartOut = %.2f", outputStats.outputFilterHeartOut);
sprintf(buf, "heartRateEst_FFT = %.2f", outputStats.heartRateEst_FFT);
sprintf(buf, "heartRateEst_FFT_4Hz = %.2f", outputStats.heartRateEst_FFT_4Hz);
sprintf(buf, "heartRateEst_xCorr = %.2f", outputStats.heartRateEst_xCorr);
sprintf(buf, "heartRateEst_peakCount_filtered = %.2f", outputStats.heartRateEst_peakCount_filtered);
sprintf(buf, "breathingRateEst_FFT = %.2f", outputStats.breathingRateEst_FFT);
sprintf(buf, "breathingRateEst_xCorr = %.2f", outputStats.breathingRateEst_xCorr);
sprintf(buf, "breathingRateEst_peakCount = %.2f", outputStats.breathingRateEst_peakCount);
sprintf(buf, "confidenceMetricBreathOut = %.2f", outputStats.confidenceMetricBreathOut);
sprintf(buf, "confidenceMetricBreathOut_xCorr = %.2f", outputStats.confidenceMetricBreathOut_xCorr);
sprintf(buf, "confidenceMetricHeartOut = %.2f", outputStats.confidenceMetricHeartOut);
sprintf(buf, "confidenceMetricHeartOut_4Hz = %.2f", outputStats.confidenceMetricHeartOut_4Hz);
sprintf(buf, "confidenceMetricHeartOut_xCorr = %.2f", outputStats.confidenceMetricHeartOut_xCorr);
sprintf(buf, "sumEnergyBreathWfm = %.2f", outputStats.sumEnergyBreathWfm);
sprintf(buf, "sumEnergyHeartWfm = %.2f", outputStats.sumEnergyHeartWfm);
sprintf(buf, "motionDetectedFlag = %.2f", outputStats.motionDetectedFlag);
sprintf(buf, "breathingRateEst_harmonicEnergy = %.2f", outputStats.breathingRateEst_harmonicEnergy);
sprintf(buf, "heartRateEst_harmonicEnergy = %.2f", outputStats.heartRateEst_harmonicEnergy);
sprintf(buf, "reserved7 = %.2f", outputStats.reserved7);
sprintf(buf, "reserved8 = %.2f", outputStats.reserved8);
sprintf(buf, "reserved9 = %.2f", outputStats.reserved9);
sprintf(buf, "reserved10 = %.2f", outputStats.reserved10);
sprintf(buf, "reserved11 = %.2f", outputStats.reserved11);
sprintf(buf, "reserved12 = %.2f", outputStats.reserved12);
sprintf(buf, "reserved13 = %.2f", outputStats.reserved13);
sprintf(buf, "reserved14 = %.2f", outputStats.reserved14);
void printTLV_head(MmwDemo_output_message_tl* TLV_head) {
printf("TLV_head type = %d\n", TLV_head->type);
printf("TLV_head length = %d\n", TLV_head->length);
appendTxtLine((char*)"\nTLV_head:");
sprintf(buf, "TLV_head type = %d", TLV_head->type);
sprintf(buf, "TLV_head length = %d", TLV_head->length);
printf("magicWord[0] = %#06x\t", head.magicWord[0]);
printf("magicWord[1] = %#06x\t", head.magicWord[1]);
printf("magicWord[2] = %#06x\t", head.magicWord[2]);
printf("magicWord[3] = %#06x\n", head.magicWord[3]);
printf("version = %#010x\n", head.version);
printf("totalPacketLen = %d\n", head.totalPacketLen);
printf("platform = %#010x\n", head.platform);
printf("frameNumber = %d\n", head.frameNumber);
printf("timeCpuCycles = %d\n", head.timeCpuCycles);
printf("numDetectedObj = %d\n", head.numDetectedObj);
printf("numTLVs = %d\n", head.numTLVs);
printf("subFrameNumber = %d\n", head.subFrameNumber);
sprintf(buf, "magicWord[0] = %#06x", head.magicWord[0]);
sprintf(buf, "magicWord[1] = %#06x", head.magicWord[1]);
sprintf(buf, "magicWord[2] = %#06x", head.magicWord[2]);
sprintf(buf, "magicWord[3] = %#06x", head.magicWord[3]);
sprintf(buf, "version = %#010x", head.version);
sprintf(buf, "totalPacketLen = %d", head.totalPacketLen);
sprintf(buf, "platform = %#010x", head.platform);
sprintf(buf, "frameNumber = %d", head.frameNumber);
sprintf(buf, "timeCpuCycles = %d", head.timeCpuCycles);
sprintf(buf, "numDetectedObj = %d", head.numDetectedObj);
sprintf(buf, "numTLVs = %d", head.numTLVs);
sprintf(buf, "subFrameNumber = %d", head.subFrameNumber);
file = fopen(FILENAME, "r");
int SIZE = sizeof(Header_t);
bytesRead = fread(&head, sizeof(Header_t), 1, file);
if (head.magicWord[0] == 0x0102 && head.magicWord[1] == 0x0304 && head.magicWord[2] == 0x0506 && head.magicWord[3] == 0x0708)
printf("找到个数当前是%d\n", i);
sprintf(buf, "\n-----------------------------------------找到个数当前是%d-----------------------------", i);
fseek(file, -SIZE + 2, SEEK_CUR);
bytesRead = fread(&TLV_head, sizeof(MmwDemo_output_message_tl), 1, file);
printTLV_head(&TLV_head);
bytesRead = fread(&outputStats, sizeof(VitalSignsDemo_OutputStats), 1, file);
bytesRead = fread(&TLV_head1, sizeof(MmwDemo_output_message_tl), 1, file);
printTLV_head(&TLV_head1);
bytesRead = fread(&tmp, 1, TLV_head1.length, file);
printf("跳过数据量:%d\n", TLV_head1.length);
printf("\n共取到了 %d个数据", j - 1);