Skip to content
Snippets Groups Projects
Commit 625bbdfc authored by Paul Best's avatar Paul Best
Browse files

better Rapport2info and log2wav

parent be0660e8
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define NTOAS_MAX 200 #define NTOAS_MAX 200
#define RORQUAL_SAMPLE_RATE 4000 #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_WINSIZE 4096
#define RORQUAL_LENSPEC (RORQUAL_LENSIG - RORQUAL_WINSIZE)/RORQUAL_HOPSIZE #define RORQUAL_LENSPEC (RORQUAL_LENSIG - RORQUAL_WINSIZE)/RORQUAL_HOPSIZE
#define RORQUAL_HOPSIZE 256 #define RORQUAL_HOPSIZE 256
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define RORQUAL_SAMPLESPERSAMPLE 8000 // see cacha #define RORQUAL_SAMPLESPERSAMPLE 8000 // see cacha
#define CACHA_SAMPLE_RATE 64000 #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_WINSIZE 512
#define CACHA_LENSPEC (CACHA_LENSIG - CACHA_WINSIZE)/CACHA_HOPSIZE #define CACHA_LENSPEC (CACHA_LENSIG - CACHA_WINSIZE)/CACHA_HOPSIZE
#define CACHA_HOPSIZE 256 #define CACHA_HOPSIZE 256
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
typedef struct{ typedef struct{
float predsC[CACHA_LENPRED]; //len of preds for 10sec signal float predsC[CACHA_LENPRED]; //len of preds for 10sec signal
bool detectionCachalot; short numDetectionsCachalot;
float predsR[RORQUAL_LENPRED]; //len of preds for 60sec signal float predsR[RORQUAL_LENPRED]; //len of preds for 60sec signal
bool detectionRorqual; short numDetectionsRorqual;
char fileName[50]; //Nom du fichier concerne char fileName[50]; //Nom du fichier concerne
int ToAs_cacha[NTOAS_MAX]; int ToAs_cacha[NTOAS_MAX];
unsigned char hydros_ToAs_cacha[NTOAS_MAX]; unsigned char hydros_ToAs_cacha[NTOAS_MAX];
...@@ -40,12 +40,14 @@ typedef struct{ ...@@ -40,12 +40,14 @@ typedef struct{
}RAPPORT; }RAPPORT;
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
FILE* infile = fopen("Rapport.info", "rb"); printf("Have you checked rorqual and cacha lensigs and config ?? (needs to match with pic32\'s)");
FILE* outfile = fopen("Rapport.txt", "w+"); FILE* infile = fopen(argv[1], "rb");
if(infile==NULL){ if(infile==NULL){
printf("Failed to open input file\n"); printf("Failed to open input file\n");
return 0; return 0;
} }
strcpy(argv[1] + strlen(argv[1])-3, "txt\0");
FILE* outfile = fopen(argv[1], "w+");
if(outfile==NULL){ if(outfile==NULL){
printf("Failed to open output file\n"); printf("Failed to open output file\n");
return 0; return 0;
...@@ -59,11 +61,11 @@ int main(int argc, char* argv[]){ ...@@ -59,11 +61,11 @@ int main(int argc, char* argv[]){
fprintf(outfile, "%f,", rapport.predsR[i]); fprintf(outfile, "%f,", rapport.predsR[i]);
} }
fprintf(outfile, "\n rorqual predPeaks\n"); 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, "%hd,", rapport.predPeaksR[i]);
} }
fprintf(outfile, "\n rorqual samples\n"); 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++){ for(j=0; j<RORQUAL_SAMPLESPERSAMPLE; j++){
fprintf(outfile, "%hd,", rapport.samplesR[i][j]); fprintf(outfile, "%hd,", rapport.samplesR[i][j]);
} }
...@@ -74,11 +76,11 @@ int main(int argc, char* argv[]){ ...@@ -74,11 +76,11 @@ int main(int argc, char* argv[]){
fprintf(outfile, "%f,", rapport.predsC[i]); fprintf(outfile, "%f,", rapport.predsC[i]);
} }
fprintf(outfile, "\n cacha predPeaks\n"); 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, "%hd,", rapport.predPeaksC[i]);
} }
fprintf(outfile, "\n cacha samples\n"); 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++){ for(j=0; j<CACHA_SAMPLESPERSAMPLE; j++){
fprintf(outfile, "%hd,", rapport.samplesC[i][j]); fprintf(outfile, "%hd,", rapport.samplesC[i][j]);
} }
......
No preview for this file type
...@@ -192,18 +192,20 @@ int main(int argc, char* argv[]){ ...@@ -192,18 +192,20 @@ int main(int argc, char* argv[]){
whdr.subChunk2Size = whdr.chunkSize-36; whdr.subChunk2Size = whdr.chunkSize-36;
fwrite(&whdr, sizeof(WaveHeader), 1, wavfile); fwrite(&whdr, sizeof(WaveHeader), 1, wavfile);
FILE* mpuFile; // open mpu file FILE* mpuFile = NULL; // open mpu file
if(argc>3){ if(argc>3){
mpuFile = fopen(argv[3], "w+"); 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){ if(mpuFile==NULL){
printf("Failed to open mpu output file\n"); printf("Failed to open mpu output file\n");
return 0; 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* dmaBlock = (char*) malloc(hdr.dmaBlockSize);
char* additionnalDataBlock = (char*) malloc(hdr.sizeOfAdditionnalDataBuffer); char* additionnalDataBlock = (char*) malloc(hdr.sizeOfAdditionnalDataBuffer);
char* samples = (char*) malloc(hdr.numberOfChan * resolutionBytes); char* samples = (char*) malloc(hdr.numberOfChan * resolutionBytes);
...@@ -213,8 +215,10 @@ int main(int argc, char* argv[]){ ...@@ -213,8 +215,10 @@ int main(int argc, char* argv[]){
// read each dataBlock // read each dataBlock
do{ do{
fread(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, 1, logfile); fread(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, 1, logfile);
if(mpuFile != NULL){
parseMPU(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, isFirst && verbose, mpuFile); parseMPU(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, isFirst && verbose, mpuFile);
isFirst = false; isFirst = false;
}
fread(dmaBlock, hdr.dmaBlockSize, 1, logfile); fread(dmaBlock, hdr.dmaBlockSize, 1, logfile);
for(isample=0; isample<dataBlockSampleSize; isample++){ for(isample=0; isample<dataBlockSampleSize; isample++){
for(ichan=0; ichan<hdr.numberOfChan; ichan++){ for(ichan=0; ichan<hdr.numberOfChan; ichan++){
...@@ -229,6 +233,8 @@ int main(int argc, char* argv[]){ ...@@ -229,6 +233,8 @@ int main(int argc, char* argv[]){
printf("\r\n"); printf("\r\n");
fclose(wavfile); fclose(wavfile);
fclose(logfile); fclose(logfile);
if(mpuFile!=NULL){
fclose(mpuFile); fclose(mpuFile);
}
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment