diff --git a/RapportInfo2txt b/RapportInfo2txt index 59fe5a683e587250009a38b299a472de5ea29320..d8e84b73ee9e0d96c09e67bcfccc60ae916699d1 100755 Binary files a/RapportInfo2txt and b/RapportInfo2txt differ diff --git a/RapportInfo2txt.c b/RapportInfo2txt.c index 7f795cec309001a7a1d031bf332128c003abf435..dabbe55862624b255cfad328f5d3aed2be1548fd 100755 --- a/RapportInfo2txt.c +++ b/RapportInfo2txt.c @@ -7,7 +7,7 @@ #define NTOAS_MAX 200 #define RORQUAL_SAMPLE_RATE 4000 -#define RORQUAL_LENSIG RORQUAL_SAMPLE_RATE*10 // load 60sec +#define RORQUAL_LENSIG RORQUAL_SAMPLE_RATE*60 // load 60sec #define RORQUAL_WINSIZE 4096 #define RORQUAL_LENSPEC (RORQUAL_LENSIG - RORQUAL_WINSIZE)/RORQUAL_HOPSIZE #define RORQUAL_HOPSIZE 256 @@ -16,7 +16,7 @@ #define RORQUAL_SAMPLESPERSAMPLE 8000 // see cacha #define CACHA_SAMPLE_RATE 64000 -#define CACHA_LENSIG CACHA_SAMPLE_RATE*10 // load 5sec +#define CACHA_LENSIG CACHA_SAMPLE_RATE*10 // load 10sec #define CACHA_WINSIZE 512 #define CACHA_LENSPEC (CACHA_LENSIG - CACHA_WINSIZE)/CACHA_HOPSIZE #define CACHA_HOPSIZE 256 @@ -27,9 +27,9 @@ typedef struct{ float predsC[CACHA_LENPRED]; //len of preds for 10sec signal - bool detectionCachalot; + short numDetectionsCachalot; float predsR[RORQUAL_LENPRED]; //len of preds for 60sec signal - bool detectionRorqual; + short numDetectionsRorqual; char fileName[50]; //Nom du fichier concerne int ToAs_cacha[NTOAS_MAX]; unsigned char hydros_ToAs_cacha[NTOAS_MAX]; @@ -40,12 +40,14 @@ typedef struct{ }RAPPORT; int main(int argc, char* argv[]){ - FILE* infile = fopen("Rapport.info", "rb"); - FILE* outfile = fopen("Rapport.txt", "w+"); + printf("Have you checked rorqual and cacha lensigs and config ?? (needs to match with pic32\'s)"); + FILE* infile = fopen(argv[1], "rb"); if(infile==NULL){ printf("Failed to open input file\n"); return 0; } + strcpy(argv[1] + strlen(argv[1])-3, "txt\0"); + FILE* outfile = fopen(argv[1], "w+"); if(outfile==NULL){ printf("Failed to open output file\n"); return 0; @@ -59,11 +61,11 @@ int main(int argc, char* argv[]){ fprintf(outfile, "%f,", rapport.predsR[i]); } fprintf(outfile, "\n rorqual predPeaks\n"); - for(i=0; i<RORQUAL_NSAMPLESTOSEND; i++){ + for(i=0; i<rapport.numDetectionsRorqual; i++){ fprintf(outfile, "%hd,", rapport.predPeaksR[i]); } fprintf(outfile, "\n rorqual samples\n"); - for(i=0; i<RORQUAL_NSAMPLESTOSEND; i++){ + for(i=0; i<rapport.numDetectionsRorqual; i++){ for(j=0; j<RORQUAL_SAMPLESPERSAMPLE; j++){ fprintf(outfile, "%hd,", rapport.samplesR[i][j]); } @@ -74,11 +76,11 @@ int main(int argc, char* argv[]){ fprintf(outfile, "%f,", rapport.predsC[i]); } fprintf(outfile, "\n cacha predPeaks\n"); - for(i=0; i<CACHA_NSAMPLESTOSEND; i++){ + for(i=0; i<rapport.numDetectionsCachalot; i++){ fprintf(outfile, "%hd,", rapport.predPeaksC[i]); } fprintf(outfile, "\n cacha samples\n"); - for(i=0; i<CACHA_NSAMPLESTOSEND; i++){ + for(i=0; i<rapport.numDetectionsCachalot; i++){ for(j=0; j<CACHA_SAMPLESPERSAMPLE; j++){ fprintf(outfile, "%hd,", rapport.samplesC[i][j]); } diff --git a/log2wav b/log2wav index 726289250c5d4f412d794e25e3f8431c916d0dbe..5b4e089bdb44cad821c22db58169183b14557125 100755 Binary files a/log2wav and b/log2wav differ diff --git a/log2wav.c b/log2wav.c index 8cd5e04d20cca111c2ae2b05e0014fbac709ba1b..d7e46203ea72cb679f28a16c69c89f5ba847ee92 100755 --- a/log2wav.c +++ b/log2wav.c @@ -192,18 +192,20 @@ int main(int argc, char* argv[]){ whdr.subChunk2Size = whdr.chunkSize-36; fwrite(&whdr, sizeof(WaveHeader), 1, wavfile); - FILE* mpuFile; // open mpu file + FILE* mpuFile = NULL; // open mpu file if(argc>3){ mpuFile = fopen(argv[3], "w+"); - }else{ - strcpy(argv[1] + strlen(argv[1])-4, "_mpu.csv\0"); - mpuFile = fopen(argv[1], "w+"); - argv[1][strlen(argv[1])-8] = '\0'; - } - if(mpuFile==NULL){ - printf("Failed to open mpu output file\n"); - return 0; + if(mpuFile==NULL){ + printf("Failed to open mpu output file\n"); + return 0; + } } + // }else{ + // strcpy(argv[1] + strlen(argv[1])-4, "_mpu.csv\0"); + // mpuFile = fopen(argv[1], "w+"); + // argv[1][strlen(argv[1])-8] = '\0'; + // } + char* dmaBlock = (char*) malloc(hdr.dmaBlockSize); char* additionnalDataBlock = (char*) malloc(hdr.sizeOfAdditionnalDataBuffer); char* samples = (char*) malloc(hdr.numberOfChan * resolutionBytes); @@ -213,8 +215,10 @@ int main(int argc, char* argv[]){ // read each dataBlock do{ fread(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, 1, logfile); - parseMPU(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, isFirst && verbose, mpuFile); - isFirst = false; + if(mpuFile != NULL){ + parseMPU(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, isFirst && verbose, mpuFile); + isFirst = false; + } fread(dmaBlock, hdr.dmaBlockSize, 1, logfile); for(isample=0; isample<dataBlockSampleSize; isample++){ for(ichan=0; ichan<hdr.numberOfChan; ichan++){ @@ -229,6 +233,8 @@ int main(int argc, char* argv[]){ printf("\r\n"); fclose(wavfile); fclose(logfile); - fclose(mpuFile); + if(mpuFile!=NULL){ + fclose(mpuFile); + } return 0; }