m10mod/mXXmod, rs41mod: raw+json output

pull/37/head
Zilog80 2021-01-01 11:06:29 +01:00
rodzic c13e34239c
commit 644b58a98b
3 zmienionych plików z 163 dodań i 136 usunięć

Wyświetl plik

@ -35,6 +35,7 @@ typedef struct {
i8_t aut;
i8_t col; // colors
i8_t jsn; // JSON output (auto_rx)
i8_t slt; // silent (only raw/json)
} option_t;
@ -870,82 +871,85 @@ static int print_pos(gpx_t *gpx, int csOK) {
get_SN(gpx);
if (gpx->option.col) {
fprintf(stdout, col_TXT);
if (gpx->type == t_M10)
{
if (gpx->option.vbs >= 3) fprintf(stdout, " (W "col_GPSweek"%d"col_TXT") ", gpx->week);
fprintf(stdout, col_GPSTOW"%s"col_TXT" ", weekday[gpx->wday]);
if ( !gpx->option.slt )
{
if (gpx->option.col) {
fprintf(stdout, col_TXT);
if (gpx->type == t_M10)
{
if (gpx->option.vbs >= 3) fprintf(stdout, " (W "col_GPSweek"%d"col_TXT") ", gpx->week);
fprintf(stdout, col_GPSTOW"%s"col_TXT" ", weekday[gpx->wday]);
}
fprintf(stdout, col_GPSdate"%04d-%02d-%02d"col_TXT" "col_GPSTOW"%02d:%02d:%06.3f"col_TXT" ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: "col_GPSlat"%.5f"col_TXT" ", gpx->lat);
fprintf(stdout, " lon: "col_GPSlon"%.5f"col_TXT" ", gpx->lon);
fprintf(stdout, " alt: "col_GPSalt"%.2f"col_TXT" ", gpx->alt);
if (!err2) {
//if (gpx->option.vbs == 2) fprintf(stdout, " "col_GPSvel"(%.1f , %.1f : %.1f)"col_TXT" ", gpx->vx, gpx->vy, gpx->vD2);
fprintf(stdout, " vH: "col_GPSvel"%.1f"col_TXT" D: "col_GPSvel"%.1f"col_TXT" vV: "col_GPSvel"%.1f"col_TXT" ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " SN: "col_SN"%s"col_TXT, gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (csOK) fprintf(stdout, " "col_CSok"[OK]"col_TXT);
else fprintf(stdout, " "col_CSno"[NO]"col_TXT);
}
if (gpx->option.ptu && csOK) {
if (gpx->T > -270.0) fprintf(stdout, " T=%.1fC", gpx->T);
if (gpx->option.vbs >= 2) { if (gpx->_RH > -0.5) fprintf(stdout, " _RH=%.0f%%", gpx->_RH); }
if (gpx->option.vbs >= 3) {
float t2 = get_Tntc2(gpx);
float fq555 = get_TLC555freq(gpx);
fprintf(stdout, " (Ti:%.1fC)", gpx->Ti);
if (t2 > -270.0) fprintf(stdout, " (T2:%.1fC) (%.3fkHz)", t2, fq555/1e3);
}
}
if (gpx->option.vbs >= 3 && csOK) {
fprintf(stdout, " (bat:%.2fV)", gpx->batV);
}
fprintf(stdout, ANSI_COLOR_RESET"");
}
fprintf(stdout, col_GPSdate"%04d-%02d-%02d"col_TXT" "col_GPSTOW"%02d:%02d:%06.3f"col_TXT" ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: "col_GPSlat"%.5f"col_TXT" ", gpx->lat);
fprintf(stdout, " lon: "col_GPSlon"%.5f"col_TXT" ", gpx->lon);
fprintf(stdout, " alt: "col_GPSalt"%.2f"col_TXT" ", gpx->alt);
if (!err2) {
//if (gpx->option.vbs == 2) fprintf(stdout, " "col_GPSvel"(%.1f , %.1f : %.1f)"col_TXT" ", gpx->vx, gpx->vy, gpx->vD2);
fprintf(stdout, " vH: "col_GPSvel"%.1f"col_TXT" D: "col_GPSvel"%.1f"col_TXT" vV: "col_GPSvel"%.1f"col_TXT" ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " SN: "col_SN"%s"col_TXT, gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (csOK) fprintf(stdout, " "col_CSok"[OK]"col_TXT);
else fprintf(stdout, " "col_CSno"[NO]"col_TXT);
}
if (gpx->option.ptu && csOK) {
if (gpx->T > -270.0) fprintf(stdout, " T=%.1fC", gpx->T);
if (gpx->option.vbs >= 2) { if (gpx->_RH > -0.5) fprintf(stdout, " _RH=%.0f%%", gpx->_RH); }
if (gpx->option.vbs >= 3) {
float t2 = get_Tntc2(gpx);
float fq555 = get_TLC555freq(gpx);
fprintf(stdout, " (Ti:%.1fC)", gpx->Ti);
if (t2 > -270.0) fprintf(stdout, " (T2:%.1fC) (%.3fkHz)", t2, fq555/1e3);
else {
if (gpx->type == t_M10)
{
if (gpx->option.vbs >= 3) fprintf(stdout, " (W %d) ", gpx->week);
fprintf(stdout, "%s ", weekday[gpx->wday]);
}
fprintf(stdout, "%04d-%02d-%02d %02d:%02d:%06.3f ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: %.5f ", gpx->lat);
fprintf(stdout, " lon: %.5f ", gpx->lon);
fprintf(stdout, " alt: %.2f ", gpx->alt);
if (!err2) {
//if (gpx->option.vbs == 2) fprintf(stdout, " (%.1f , %.1f : %.1f) ", gpx->vx, gpx->vy, gpx->vD2);
fprintf(stdout, " vH: %.1f D: %.1f vV: %.1f ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " SN: %s", gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (csOK) fprintf(stdout, " [OK]"); else fprintf(stdout, " [NO]");
}
if (gpx->option.ptu && csOK) {
if (gpx->T > -270.0) fprintf(stdout, " T=%.1fC", gpx->T);
if (gpx->option.vbs >= 2) { if (gpx->_RH > -0.5) fprintf(stdout, " _RH=%.0f%%", gpx->_RH); }
if (gpx->option.vbs >= 3) {
float t2 = get_Tntc2(gpx);
float fq555 = get_TLC555freq(gpx);
fprintf(stdout, " (Ti:%.1fC)", gpx->Ti);
if (t2 > -270.0) fprintf(stdout, " (T2:%.1fC) (%.3fkHz)", t2, fq555/1e3);
}
}
if (gpx->option.vbs >= 3 && csOK) {
fprintf(stdout, " (bat:%.2fV)", gpx->batV);
}
}
if (gpx->option.vbs >= 3 && csOK) {
fprintf(stdout, " (bat:%.2fV)", gpx->batV);
}
fprintf(stdout, ANSI_COLOR_RESET"");
fprintf(stdout, "\n");
}
else {
if (gpx->type == t_M10)
{
if (gpx->option.vbs >= 3) fprintf(stdout, " (W %d) ", gpx->week);
fprintf(stdout, "%s ", weekday[gpx->wday]);
}
fprintf(stdout, "%04d-%02d-%02d %02d:%02d:%06.3f ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: %.5f ", gpx->lat);
fprintf(stdout, " lon: %.5f ", gpx->lon);
fprintf(stdout, " alt: %.2f ", gpx->alt);
if (!err2) {
//if (gpx->option.vbs == 2) fprintf(stdout, " (%.1f , %.1f : %.1f) ", gpx->vx, gpx->vy, gpx->vD2);
fprintf(stdout, " vH: %.1f D: %.1f vV: %.1f ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " SN: %s", gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (csOK) fprintf(stdout, " [OK]"); else fprintf(stdout, " [NO]");
}
if (gpx->option.ptu && csOK) {
if (gpx->T > -270.0) fprintf(stdout, " T=%.1fC", gpx->T);
if (gpx->option.vbs >= 2) { if (gpx->_RH > -0.5) fprintf(stdout, " _RH=%.0f%%", gpx->_RH); }
if (gpx->option.vbs >= 3) {
float t2 = get_Tntc2(gpx);
float fq555 = get_TLC555freq(gpx);
fprintf(stdout, " (Ti:%.1fC)", gpx->Ti);
if (t2 > -270.0) fprintf(stdout, " (T2:%.1fC) (%.3fkHz)", t2, fq555/1e3);
}
}
if (gpx->option.vbs >= 3 && csOK) {
fprintf(stdout, " (bat:%.2fV)", gpx->batV);
}
}
fprintf(stdout, "\n");
if (gpx->option.jsn) {
@ -1092,7 +1096,9 @@ static int print_frame(gpx_t *gpx, int pos, int b2B) {
}
fprintf(stdout, "\n");
}
if (gpx->option.slt /*&& gpx->option.jsn*/) {
print_pos(gpx, cs1 == cs2);
}
}
else if (gpx->frame_bytes[1] == 0x49) {
if (gpx->option.vbs == 3) {
@ -1204,6 +1210,7 @@ int main(int argc, char **argv) {
else if (strcmp(*argv, "--chk3") == 0) { option_chk = 3; }
else if (strcmp(*argv, "--ch2") == 0) { sel_wavch = 1; } // right channel (default: 0=left)
else if (strcmp(*argv, "--softin") == 0) { option_softin = 1; } // float32 soft input
else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; }
else if (strcmp(*argv, "--ths") == 0) {
++argv;
if (*argv) {
@ -1277,6 +1284,8 @@ int main(int argc, char **argv) {
if (!wavloaded) fp = stdin;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;
// init gpx
gpx.option.inv = option_inv; // irrelevant
gpx.option.vbs = option_verbose;

Wyświetl plik

@ -42,6 +42,7 @@ typedef struct {
i8_t aut;
i8_t col; // colors
i8_t jsn; // JSON output (auto_rx)
i8_t slt; // silent (only raw/json)
} option_t;
@ -562,69 +563,74 @@ static int print_pos(gpx_t *gpx, int bcOK, int csOK) {
Gps2Date(gpx->week, gpx->gpssec, &gpx->jahr, &gpx->monat, &gpx->tag);
get_SN(gpx);
if (gpx->option.col) {
fprintf(stdout, col_TXT);
if (gpx->option.vbs >= 3) {
fprintf(stdout, "[%3d]", gpx->frame_bytes[pos_CNT]);
fprintf(stdout, " (W "col_GPSweek"%d"col_TXT") ", gpx->week);
}
fprintf(stdout, col_GPSTOW"%s"col_TXT" ", weekday[gpx->wday]);
fprintf(stdout, col_GPSdate"%04d-%02d-%02d"col_TXT" "col_GPSTOW"%02d:%02d:%06.3f"col_TXT" ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: "col_GPSlat"%.5f"col_TXT" ", gpx->lat);
fprintf(stdout, " lon: "col_GPSlon"%.5f"col_TXT" ", gpx->lon);
fprintf(stdout, " alt: "col_GPSalt"%.2f"col_TXT" ", gpx->alt);
if (!err2) {
fprintf(stdout, " vH: "col_GPSvel"%.1f"col_TXT" D: "col_GPSvel"%.1f"col_TXT" vV: "col_GPSvel"%.1f"col_TXT" ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2 && (bcOK || csOK)) { // SN
fprintf(stdout, " SN: "col_SN"%s"col_TXT, gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (bcOK) fprintf(stdout, " "col_CSok"(ok)"col_TXT);
else fprintf(stdout, " "col_CSno"(no)"col_TXT);
if (csOK) fprintf(stdout, " "col_CSok"[OK]"col_TXT);
else fprintf(stdout, " "col_CSno"[NO]"col_TXT);
}
if (gpx->option.ptu && csOK) {
if ( !gpx->option.slt )
{
if (gpx->option.col) {
fprintf(stdout, col_TXT);
if (gpx->option.vbs >= 3) {
float t0 = get_Tntc0(gpx);
if (t0 > -270.0) fprintf(stdout, " (T0:%.1fC) ", t0);
fprintf(stdout, "[%3d]", gpx->frame_bytes[pos_CNT]);
fprintf(stdout, " (W "col_GPSweek"%d"col_TXT") ", gpx->week);
}
fprintf(stdout, col_GPSTOW"%s"col_TXT" ", weekday[gpx->wday]);
fprintf(stdout, col_GPSdate"%04d-%02d-%02d"col_TXT" "col_GPSTOW"%02d:%02d:%06.3f"col_TXT" ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: "col_GPSlat"%.5f"col_TXT" ", gpx->lat);
fprintf(stdout, " lon: "col_GPSlon"%.5f"col_TXT" ", gpx->lon);
fprintf(stdout, " alt: "col_GPSalt"%.2f"col_TXT" ", gpx->alt);
if (!err2) {
fprintf(stdout, " vH: "col_GPSvel"%.1f"col_TXT" D: "col_GPSvel"%.1f"col_TXT" vV: "col_GPSvel"%.1f"col_TXT" ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2 && (bcOK || csOK)) { // SN
fprintf(stdout, " SN: "col_SN"%s"col_TXT, gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (bcOK) fprintf(stdout, " "col_CSok"(ok)"col_TXT);
else fprintf(stdout, " "col_CSno"(no)"col_TXT);
if (csOK) fprintf(stdout, " "col_CSok"[OK]"col_TXT);
else fprintf(stdout, " "col_CSno"[NO]"col_TXT);
}
if (gpx->option.ptu && csOK) {
if (gpx->option.vbs >= 3) {
float t0 = get_Tntc0(gpx);
if (t0 > -270.0) fprintf(stdout, " (T0:%.1fC) ", t0);
}
}
fprintf(stdout, ANSI_COLOR_RESET"");
}
else {
if (gpx->option.vbs >= 3) {
fprintf(stdout, "[%3d]", gpx->frame_bytes[pos_CNT]);
fprintf(stdout, " (W %d) ", gpx->week);
}
fprintf(stdout, "%s ", weekday[gpx->wday]);
fprintf(stdout, "%04d-%02d-%02d %02d:%02d:%06.3f ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: %.5f ", gpx->lat);
fprintf(stdout, " lon: %.5f ", gpx->lon);
fprintf(stdout, " alt: %.2f ", gpx->alt);
if (!err2) {
fprintf(stdout, " vH: %.1f D: %.1f vV: %.1f ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2 && (bcOK || csOK)) { // SN
fprintf(stdout, " SN: %s", gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (bcOK) fprintf(stdout, " (ok)"); else fprintf(stdout, " (no)");
if (csOK) fprintf(stdout, " [OK]"); else fprintf(stdout, " [NO]");
}
if (gpx->option.ptu && csOK) {
if (gpx->option.vbs >= 3) {
float t0 = get_Tntc0(gpx);
if (t0 > -270.0) fprintf(stdout, " (T0:%.1fC) ", t0);
}
}
}
fprintf(stdout, ANSI_COLOR_RESET"");
fprintf(stdout, "\n");
}
else {
if (gpx->option.vbs >= 3) {
fprintf(stdout, "[%3d]", gpx->frame_bytes[pos_CNT]);
fprintf(stdout, " (W %d) ", gpx->week);
}
fprintf(stdout, "%s ", weekday[gpx->wday]);
fprintf(stdout, "%04d-%02d-%02d %02d:%02d:%06.3f ",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
fprintf(stdout, " lat: %.5f ", gpx->lat);
fprintf(stdout, " lon: %.5f ", gpx->lon);
fprintf(stdout, " alt: %.2f ", gpx->alt);
if (!err2) {
fprintf(stdout, " vH: %.1f D: %.1f vV: %.1f ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2 && (bcOK || csOK)) { // SN
fprintf(stdout, " SN: %s", gpx->SN);
}
if (gpx->option.vbs >= 2) {
fprintf(stdout, " # ");
if (bcOK) fprintf(stdout, " (ok)"); else fprintf(stdout, " (no)");
if (csOK) fprintf(stdout, " [OK]"); else fprintf(stdout, " [NO]");
}
if (gpx->option.ptu && csOK) {
if (gpx->option.vbs >= 3) {
float t0 = get_Tntc0(gpx);
if (t0 > -270.0) fprintf(stdout, " (T0:%.1fC) ", t0);
}
}
}
fprintf(stdout, "\n");
if (gpx->option.jsn) {
// Print out telemetry data as JSON
@ -730,7 +736,9 @@ static int print_frame(gpx_t *gpx, int pos, int b2B) {
}
fprintf(stdout, "\n");
}
if (gpx->option.slt /*&& gpx->option.jsn*/) {
print_pos(gpx, bc1 == bc2, cs1 == cs2);
}
}
/*
else if (gpx->frame_bytes[1] == 0x49) {
@ -852,6 +860,7 @@ int main(int argc, char **argv) {
}
else if ( (strcmp(*argv, "--ch2") == 0) ) { sel_wavch = 1; } // right channel (default: 0=left)
else if (strcmp(*argv, "--softin") == 0) { option_softin = 1; } // float32 soft input
else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; }
else if ( (strcmp(*argv, "--ths") == 0) ) {
++argv;
if (*argv) {
@ -925,6 +934,8 @@ int main(int argc, char **argv) {
if (!wavloaded) fp = stdin;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;
// init gpx
gpx.option.inv = option_inv; // irrelevant
gpx.option.vbs = option_verbose;

Wyświetl plik

@ -52,7 +52,7 @@ typedef struct {
i8_t inv;
i8_t aut;
i8_t jsn; // JSON output (auto_rx)
i8_t slt; // silent
i8_t slt; // silent (only raw/json)
} option_t;
typedef struct {
@ -1472,7 +1472,7 @@ static int prn_ptu(gpx_t *gpx) {
}
static int prn_gpstime(gpx_t *gpx) {
Gps2Date(gpx);
//Gps2Date(gpx);
fprintf(stdout, "%s ", weekday[gpx->wday]);
fprintf(stdout, "%04d-%02d-%02d %02d:%02d:%06.3f",
gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek);
@ -1638,6 +1638,7 @@ static int print_position(gpx_t *gpx, int ec) {
ofs = pos - pos_GPS1;
err1 = get_GPS1(gpx, ofs);
if ( !err1 ) {
Gps2Date(gpx);
if (out) prn_gpstime(gpx);
if (sat) prn_sat1(gpx, ofs);
}
@ -1780,6 +1781,7 @@ static int print_position(gpx_t *gpx, int ec) {
err1 = get_GPS1(gpx, ofs);
err2 = get_GPS2(gpx, ofs);
err3 = get_GPS3(gpx, ofs);
if (!err1) Gps2Date(gpx);
if (out) {
@ -1894,6 +1896,9 @@ static void print_frame(gpx_t *gpx, int len) {
}
}
fprintf(stdout, "\n");
if (gpx->option.slt /*&& gpx->option.jsn*/) {
print_position(gpx, ec);
}
}
else {
print_position(gpx, ec);
@ -1995,11 +2000,11 @@ int main(int argc, char *argv[]) {
else if (strcmp(*argv, "--ptu" ) == 0) { gpx.option.ptu = 1; }
else if (strcmp(*argv, "--ptu2") == 0) { gpx.option.ptu = 2; }
else if (strcmp(*argv, "--dewp") == 0) { gpx.option.dwp = 1; }
else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; }
else if (strcmp(*argv, "--ch2") == 0) { sel_wavch = 1; } // right channel (default: 0=left)
else if (strcmp(*argv, "--auto") == 0) { gpx.option.aut = 1; }
else if (strcmp(*argv, "--bin") == 0) { option_bin = 1; } // bit/byte binary input
else if (strcmp(*argv, "--softin") == 0) { option_softin = 1; } // float32 soft input
else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; }
else if (strcmp(*argv, "--ths") == 0) {
++argv;
if (*argv) {
@ -2086,6 +2091,8 @@ int main(int argc, char *argv[]) {
if (!wavloaded) fp = stdin;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;
if (gpx.option.ecc < 2) gpx.option.ecc = 1; // turn off for ber-measurement
if (gpx.option.ecc) {