Skip to content

Commit 0bd1604

Browse files
committed
Added das1 b0 pkt diagnostic
1 parent bd5575c commit 0bd1604

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

utilities/das2_from_tagged_das1.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ typedef struct { /* Defaults: */
108108
das_units utZvals; /* UNIT_E_SPECDENS (see units.h) */
109109
double dFillValue; /* 1E31 */
110110
double dBaseTime; /* Required input */
111+
bool bDump; /* Diagnostic output instead of das2 stream */
111112
} Options;
112113

113114
#define ST_ASCII 0
@@ -146,6 +147,8 @@ void show_help(FILE *h)
146147
"\n"
147148
" -tBeg STRING Begin time of data capture (required)\n"
148149
"\n"
150+
" -diag Suppress normal output, write ascii packet contents to\n"
151+
" stdout\n"
149152
);
150153
}
151154

@@ -165,6 +168,9 @@ void getCmdOpts(int argc, char** argv, Options* pOpts){
165168
else if(!strcmp("-s",*argv)){
166169
pOpts->bSilent=true;
167170
}
171+
else if(!strcmp("-diag",*argv)){
172+
pOpts->bDump=true;
173+
}
168174
else if(!strcmp("-t",*argv)){
169175
--argc; ++argv;
170176
nTmp = strtoul(*argv,NULL,10);
@@ -330,7 +336,7 @@ PktDesc* sendPktDesc(
330336
PktDesc_addPlane(pPd, pPlane);
331337

332338
if(!pOpts->bSilent) fprintf(stderr,"done\n DasIO_writePktDesc...");
333-
DasIO_writePktDesc(pOut, pPd);
339+
if(!pOpts->bDump) DasIO_writePktDesc(pOut, pPd);
334340
if(!pOpts->bSilent) fprintf(stderr,"done\n");
335341

336342
++g_nPktType;
@@ -420,7 +426,7 @@ int main(int argc,char *argv[])
420426
char* sProgName = argv[0];
421427

422428
Options opts = {false, ST_FLOAT, EPOCH_1958, 128.0, 0.0,
423-
UNIT_HERTZ, UNIT_E_SPECDENS, -1E31, -1.0};
429+
UNIT_HERTZ, UNIT_E_SPECDENS, -1E31, -1.0, false};
424430

425431
/* Exit on errors, log info messages and above */
426432
das_init(argv[0], DASERR_DIS_EXIT, 0, DASLOG_INFO, NULL);
@@ -448,7 +454,7 @@ int main(int argc,char *argv[])
448454
DasDesc_setDouble((DasDesc*)pSd,"zFill", opts.dFillValue);
449455

450456
if(!opts.bSilent) fprintf(stderr,"done, Send Stream Header...");
451-
DasIO_writeStreamDesc(pOut, pSd);
457+
if(!opts.bDump) DasIO_writeStreamDesc(pOut, pSd);
452458
if(!opts.bSilent) fprintf(stderr,"done\n\n");
453459

454460
int nNumPkt = 0;
@@ -467,7 +473,15 @@ int main(int argc,char *argv[])
467473
arTime[i]=*(pF++); /* C Increment operator notes: */
468474
arFreq[i]=*(pF++); /* p++ (as suffix) returns old value, but */
469475
arAmpl[i]=*(pF++); /* ++p (as prefix) returns new value */
476+
477+
if(opts.bDump){
478+
if(i==0)
479+
printf("%9.3f %9.3e %9.3e", arTime[i], arFreq[i], arAmpl[i]);
480+
else
481+
printf(",%9.3f %9.3e %9.3e", arTime[i], arFreq[i], arAmpl[i]);
482+
}
470483
}
484+
if(opts.bDump) printf("\n");
471485

472486
/* sort by frequencies to enable das2 streams to work */
473487
SwapSort_Min(arFreq,nItems,arSort);
@@ -508,7 +522,7 @@ int main(int argc,char *argv[])
508522
PlaneDesc_setValue(pYScan, i, arAmpl[arSort[i]]);
509523
}
510524

511-
DasIO_writePktData(pOut, pPd);
525+
if(!opts.bDump) DasIO_writePktData(pOut, pPd);
512526

513527
++nNumPkt;
514528
}

0 commit comments

Comments
 (0)