Rebase demodulators

pull/638/head
Mark Jessop 2022-07-08 10:39:11 +09:30
rodzic cc8afae366
commit 06a61115c7
8 zmienionych plików z 1831 dodań i 39 usunięć

Wyświetl plik

@ -536,8 +536,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) {
// prnGPS,prnTPU
if (gpx->option.jsn && frm_ok && crc_ok && (gpx->status&0x30)==0x30) {
char *ver_jsn = NULL;
//char *subtype = (rs_type == 54) ? "IMET54" : "IMET50";
char *subtype = (rs_type == 54) ? "iMet-54" : "iMet-50";
char *subtype = (rs_type == 54) ? "IMET54" : "IMET50";
unsigned long count_day = (unsigned long)(gpx->std*3600 + gpx->min*60 + gpx->sek+0.5); // (gpx->timems/1e3+0.5) has gaps
fprintf(stdout, "{ \"type\": \"%s\"", "IMET5");
fprintf(stdout, ", \"frame\": %lu", count_day);
@ -553,8 +552,13 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) {
}
fprintf(stdout, ", \"subtype\": \"%s\"", subtype); // "IMET54"/"IMET50"
if (gpx->jsn_freq > 0) {
fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq);
fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq );
}
// Reference time/position
fprintf(stdout, ", \"ref_datetime\": \"%s\"", "UTC" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
fprintf(stdout, ", \"ref_position\": \"%s\"", "MSL" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -646,6 +650,7 @@ int main(int argc, char *argv[]) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_softin = 0;
int option_pcmraw = 0;
int wavloaded = 0;
@ -762,16 +767,18 @@ int main(int argc, char *argv[]) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 24.0) lpIQ_bw = bw*1e3;
option_lp = 1;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -815,6 +822,13 @@ int main(int argc, char *argv[]) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;

Wyświetl plik

@ -778,6 +778,11 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) {
if (gpx->jsn_freq > 0) {
printf(", \"freq\": %d", gpx->jsn_freq);
}
// Reference time/position
printf(", \"ref_datetime\": \"%s\"", "GPS" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
printf(", \"ref_position\": \"%s\"", "GPS" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -914,7 +919,7 @@ static void proc_frame(gpx_t *gpx, int len) {
printf("\n");
}
print_frame(gpx, crc_err, len);
if (gpx->option.raw == 0) print_frame(gpx, crc_err, len);
gpx->frm_pos = 0;
gpx->sf6 = 0;
@ -994,6 +999,7 @@ int main(int argc, char **argv) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_softin = 0;
int option_pcmraw = 0;
int wavloaded = 0;
@ -1128,16 +1134,18 @@ int main(int argc, char **argv) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 24.0) lpIQ_bw = bw*1e3;
option_lp = 1;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -1181,6 +1189,13 @@ int main(int argc, char **argv) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
if (gpx->option.raw == 4) gpx->option.ecc = 1;
@ -1260,7 +1275,7 @@ int main(int argc, char **argv) {
dsp.opt_iq = option_iq;
dsp.opt_iqdc = option_iqdc;
dsp.opt_lp = option_lp;
dsp.lpIQ_bw = lpIQ_bw; // 16e3; // IF lowpass bandwidth // soft decoding?
dsp.lpIQ_bw = lpIQ_bw; //16e3; // IF lowpass bandwidth // soft decoding?
dsp.lpFM_bw = 6e3; // FM audio lowpass
dsp.opt_dc = option_dc;
dsp.opt_IFmin = option_min;

Wyświetl plik

@ -657,7 +657,7 @@ static float get_Temp(gpx_t *gpx) {
// [ 30.0 , 4.448 ]
// [ 35.0 , 3.704 ]
// [ 40.0 , 3.100 ]
// -> SteinhartHart coefficients (polyfit):
// -> Steinhart-Hart coefficients (polyfit):
float p0 = 1.07303516e-03,
p1 = 2.41296733e-04,
p2 = 2.26744154e-06,
@ -753,7 +753,7 @@ static float get_Tntc2(gpx_t *gpx) {
// float R25 = 2.2e3;
// float b = 3650.0; // B/Kelvin
// float T25 = 25.0 + 273.15; // T0=25C, R0=R25=5k
// -> SteinhartHart coefficients (polyfit):
// -> Steinhart-Hart coefficients (polyfit):
float p0 = 4.42606809e-03,
p1 = -6.58184309e-04,
p2 = 8.95735557e-05,
@ -1026,6 +1026,12 @@ static int print_pos(gpx_t *gpx, int csOK) {
if (gpx->jsn_freq > 0) {
fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq);
}
// Reference time/position (M10 time ref UTC only for json)
fprintf(stdout, ", \"ref_datetime\": \"%s\"", "UTC" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
fprintf(stdout, ", \"ref_position\": \"%s\"", "GPS" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
fprintf(stdout, ", \"gpsutc_leapsec\": %d", gpx->utc_ofs); // GPS-UTC offset, utc_s = gpx->gpssec - gpx->utc_ofs;
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -1143,6 +1149,7 @@ int main(int argc, char **argv) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_chk = 0;
int option_softin = 0;
int option_pcmraw = 0;
@ -1170,6 +1177,8 @@ int main(int argc, char **argv) {
float thres = 0.76;
float _mv = 0.0;
float lpIQ_bw = 24e3;
int symlen = 2;
int bitofs = 0; // 0 .. +2
int shift = 0;
@ -1254,8 +1263,18 @@ int main(int argc, char **argv) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 48.0) lpIQ_bw = bw*1e3;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -1296,6 +1315,13 @@ int main(int argc, char **argv) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;
@ -1356,7 +1382,7 @@ int main(int argc, char **argv) {
dsp.opt_iq = option_iq;
dsp.opt_iqdc = option_iqdc;
dsp.opt_lp = option_lp;
dsp.lpIQ_bw = 24e3; // IF lowpass bandwidth
dsp.lpIQ_bw = lpIQ_bw; //24e3; // IF lowpass bandwidth
dsp.lpFM_bw = 10e3; // FM audio lowpass
dsp.opt_dc = option_dc;
dsp.opt_IFmin = option_min;

1383
demod/mod/mXXmod.c 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -74,6 +74,7 @@ Variante 2 (iMS-100 ?)
0x11..0x12 31xx, xx=C1(ims100?),A2(rs11?)
0x17..0x18 16 bit 1024-counter yyxx, +0x400=1024; rollover synchron zu ms-counter, nach rollover auch +0x300=768
0x1B..0x1D HEADER 0xFB6230
0x20..0x21 16 bit GPS-vV * 1.944e1 (knots)
0x22..0x23 yy00..yy03 (yy00: GPS PRN?)
@ -145,6 +146,9 @@ typedef struct {
float sn; // 0 mod 16
float fq; // 15 mod 64
int jsn_freq; // freq/kHz (SDR)
int frm0_count; int frm0_valid;
int frm1_count; int frm1_valid;
int vV_valid;
RS_t RS;
} gpx_t;
@ -254,6 +258,7 @@ int main(int argc, char **argv) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_softin = 0;
int option_pcmraw = 0;
int sel_wavch = 0;
@ -305,6 +310,8 @@ int main(int argc, char **argv) {
float thres = 0.7;
float _mv = 0.0;
float lpIQ_bw = 16e3;
int symlen = 1;
int bitofs = 0; // 0..+1
int shift = 0;
@ -389,8 +396,18 @@ int main(int argc, char **argv) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if ( (strcmp(*argv, "--dc") == 0) ) { option_dc = 1; }
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 32.0) lpIQ_bw = bw*1e3;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -435,6 +452,13 @@ int main(int argc, char **argv) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
if (cfreq > 0) gpx.jsn_freq = (cfreq+500)/1000;
@ -490,7 +514,7 @@ int main(int argc, char **argv) {
dsp.opt_iq = option_iq;
dsp.opt_iqdc = option_iqdc;
dsp.opt_lp = option_lp;
dsp.lpIQ_bw = 16e3; // IF lowpass bandwidth
dsp.lpIQ_bw = lpIQ_bw; //16e3; // IF lowpass bandwidth
dsp.lpFM_bw = 4e3; // FM audio lowpass
dsp.opt_dc = option_dc;
dsp.opt_IFmin = option_min;
@ -716,6 +740,11 @@ int main(int argc, char **argv) {
if (gpx.fq > 0) { // include frequency derived from subframe information if available
fprintf(stdout, ", \"tx_frequency\": %.0f", gpx.fq );
}
// Reference time/position
printf(", \"ref_datetime\": \"%s\"", "UTC" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
printf(", \"ref_position\": \"%s\"", "MSL" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -826,7 +855,7 @@ int main(int argc, char **argv) {
val = bits2val(subframe_bits+HEADLEN, 16);
counter = val & 0xFFFF;
if (counter % 2 == 0) printf("[%d] ", counter);
/*if (counter % 2 == 0)*/ printf("[%d] ", counter);
w16[0] = bits2val(subframe_bits+HEADLEN+46*1 , 16);
w16[1] = bits2val(subframe_bits+HEADLEN+46*1+17, 16);
@ -911,25 +940,52 @@ int main(int argc, char **argv) {
printf(" (vH: %.1fm/s D: %.2f)", gpx.vH, gpx.vD);
printf(" ");
}
if (counter % 2 == 1) {
// cf. DF9DQ
vU = bits2val(subframe_bits+HEADLEN+46*0+17, 16);
velU = (double)vU/1.94384e1; // knots -> m/s
gpx.vV = velU;
gpx.vV_valid = (vU != 0);
if (gpx.vV_valid) {
printf(" (vV: %.1fm/s)", gpx.vV);
}
else {
printf(" (vV: --- m/s)");
}
printf(" ");
}
if (counter % 2 == 0) {
gpx.frm0_count = counter;
if (option_ecc) {
if (gps_err) printf("(no)"); else printf("(ok)");
if (err_frm) printf("[NO]"); else printf("[OK]");
gpx.frm0_valid = (err_frm==0 && gps_err==0);
}
if (option_verbose) {
if (sn > 0) {
if (sn > 0) { // cfg[0,16,32,48]=SN
printf(" : sn %.0f", sn);
sn = -1;
}
if (freq > 0) {
}
printf("\n");
}
if (counter % 2 == 1) {
gpx.frm1_count = counter;
if (option_ecc) {
if (gps_err) printf("(no)"); else printf("(ok)");
if (err_frm) printf("[NO]"); else printf("[OK]");
gpx.frm1_valid = (err_frm==0 && gps_err==0);
}
if (option_verbose) {
if (freq > 0) { // cfg[15]=freq
printf(" : fq %.0f", freq); // kHz
freq = -1;
}
}
printf("\n");
if (option_jsn && err_frm==0 && gps_err==0) {
if (option_jsn && gpx.frm0_valid) {
char *ver_jsn = NULL;
char id_str[] = "xxxxxx\0\0\0\0\0\0";
if (gpx.sn > 0 && gpx.sn < 1e9) {
@ -938,6 +994,9 @@ int main(int argc, char **argv) {
printf("{ \"type\": \"%s\"", "MEISEI"); // alt: "IMS100"
printf(", \"frame\": %d, \"id\": \"IMS100-%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f",
gpx.frnr, id_str, gpx.jahr, gpx.monat, gpx.tag, gpx.std, gpx.min, gpx.sek, gpx.lat, gpx.lon, gpx.alt, gpx.vH, gpx.vD );
if (gpx.frm1_valid && (gpx.frm1_count == gpx.frm0_count + 1)) {
if (gpx.vV_valid) printf(", \"vel_v\": %.5f", gpx.vV );
}
printf(", \"subtype\": \"IMS100\"");
if (gpx.jsn_freq > 0) { // not gpx.fq, because gpx.sn not in every frame
printf(", \"freq\": %d", gpx.jsn_freq);
@ -945,12 +1004,19 @@ int main(int argc, char **argv) {
if (gpx.fq > 0) { // include frequency derived from subframe information if available
fprintf(stdout, ", \"tx_frequency\": %.0f", gpx.fq );
}
// Reference time/position
printf(", \"ref_datetime\": \"%s\"", "UTC" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
printf(", \"ref_position\": \"%s\"", "MSL" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
printf(" }\n");
printf("\n");
gpx.frm0_valid = 0;
}
}

Wyświetl plik

@ -677,6 +677,11 @@ static void print_gpx(gpx_t *gpx, int crcOK) {
if (gpx->jsn_freq > 0) {
printf(", \"freq\": %d", gpx->jsn_freq);
}
// Reference time/position
printf(", \"ref_datetime\": \"%s\"", "UTC" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
printf(", \"ref_position\": \"%s\"", "GPS" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -772,6 +777,7 @@ int main(int argc, char **argv) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_softin = 0;
int option_pcmraw = 0;
int wavloaded = 0;
@ -883,16 +889,18 @@ int main(int argc, char **argv) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 24.0) lpIQ_bw = bw*1e3;
option_lp = 1;
if (bw > 4.6 && bw < 32.0) lpIQ_bw = bw*1e3;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -935,6 +943,14 @@ int main(int argc, char **argv) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
gpx.jsn_freq = 0;
if (cfreq > 0) gpx.jsn_freq = (cfreq+500)/1000;

Wyświetl plik

@ -60,6 +60,7 @@ typedef struct {
i8_t sat; // GPS sat data
i8_t ptu; // PTU: temperature humidity (pressure)
i8_t dwp; // PTU derived: dew point
i8_t aux; // decode xdata
i8_t inv;
i8_t aut;
i8_t jsn; // JSON output (auto_rx)
@ -454,10 +455,16 @@ static int get_SondeID(gpx_t *gpx, int crc, int ofs) {
gpx->conf_cd = -1;
gpx->conf_kt = -1;
// don't reset gpx->frame[] !
gpx->T = -273.15;
gpx->RH = -1.0;
gpx->P = -1.0;
gpx->RH2 = -1.0;
gpx->jahr = 0; gpx->monat = 0; gpx->tag = 0;
gpx->std = 0; gpx->min = 0; gpx->sek = 0.0;
gpx->week = 0;
gpx->lat = 0.0; gpx->lon = 0.0; gpx->alt = 0.0;
gpx->vH = 0.0; gpx->vD = 0.0; gpx->vV = 0.0;
gpx->numSV = 0;
gpx->T = -273.15f;
gpx->RH = -1.0f;
gpx->P = -1.0f;
gpx->RH2 = -1.0f;
// new ID:
memcpy(gpx->id, sondeid_bytes, 8);
gpx->id[8] = '\0';
@ -1063,12 +1070,217 @@ static int get_GPS3(gpx_t *gpx, int ofs) {
return err;
}
static int hex2uint(char *str, int nibs) {
int i;
int erg = 0;
int h = 0;
if (nibs > 7) return -2;
for (i = 0; i < nibs; i++) { // MSB i.e. most significant nibble first
if (str[i] >= '0' && str[i] <= '9') h = str[i]-'0';
else if (str[i] >= 'a' && str[i] <= 'f') h = str[i]-'a'+0xA;
else if (str[i] >= 'A' && str[i] <= 'F') h = str[i]-'A'+0xA;
else return -1;
erg = (erg << 4) | (h & 0xF);
}
return erg;
}
static int prn_aux_IDx01(char *xdata) {
// V7 ECC (Electrochemical Concentration Cell) Ozonesonde
// https://gml.noaa.gov/aftp/user/jordan/iMet%20Radiosonde%20Protocol.pdf
// https://harbor.weber.edu/Hardware/Ozonesonde/ECC_Ozonesonde-1.pdf
// ID=0x01: ECC Ozonesonde
// N=2*8 nibs (1byte = 2nibs) (MSB)
// 0 2 u8 Instrument_type = 0x01 (ID)
// 2 2 u8 Instrument_number
// 4 4 u16 Icell, uA (I = n/1000)
// 8 4 i16 Tpump, C (T = n/100)
// 12 2 u8 Ipump, mA
// 14 2 u8 Vbat, (V = n/10)
//
int val;
i16_t Tpump;
ui16_t Icell;
ui8_t InstrNum, Ipump, Vbat;
char *px = xdata;
int N = 2*8;
if (*px) {
if (strncmp(px, "01", 2) != 0) {
px = strstr(xdata, "#01");
if (px == NULL) return -1;
else px += 1;
}
if (strlen(px) < N) return -1;
fprintf(stdout, " ID=0x01 ECC ");
val = hex2uint(px+ 2, 2); if (val < 0) return -1;
InstrNum = val & 0xFF;
val = hex2uint(px+ 4, 4); if (val < 0) return -1;
Icell = val & 0xFFFF; // u16
val = hex2uint(px+ 8, 4); if (val < 0) return -1;
Tpump = val & 0xFFFF; // i16
val = hex2uint(px+12, 2); if (val < 0) return -1;
Ipump = val & 0xFF; // u8
val = hex2uint(px+14, 2); if (val < 0) return -1;
Vbat = val & 0xFF; // u8
fprintf(stdout, " No.%d ", InstrNum);
fprintf(stdout, " Icell:%.3fuA ", Icell/1000.0);
fprintf(stdout, " Tpump:%.2fC ", Tpump/100.0);
fprintf(stdout, " Ipump:%dmA ", Ipump);
fprintf(stdout, " Vbat:%.1fV ", Vbat/10.0);
}
else {
return -2;
}
return 0;
}
static int prn_aux_IDx05(char *xdata) {
// OIF411
// "Ozone Sounding with Vaisala Radiosonde RS41" user's guide M211486EN
//
// ID=0x05: OIF411
// pos nibs (MSB)
// 0 2 u8 Instrument_type = 0x05 (ID)
// 2 2 u8 Instrument_number
// Measurement Data, N=2*10
// 4 4 i16 Tpump, C (T = n/100)
// 8 5 u20 Icell, uA (I = n/10000)
// 13 2 u8 Vbat, (V = n/10)
// 15 3 u12 Ipump, mA
// 18 2 u8 Vext, (V = n/10)
// ID Data, N=2*10+1
// 4 8 char OIF411 Serial
// 12 4 u16 Diagnostics Word
// 16 2?4 u16? SW version (n/100)
// 20 1 char I
//
char *px = xdata;
int N = 2*10;
int val;
ui8_t InstrNum;
if (*px) {
if (strncmp(px, "05", 2) != 0) {
px = strstr(xdata, "#05");
if (px == NULL) return -1;
else px += 1;
}
if (strlen(px) < N) return -1;
fprintf(stdout, " ID=0x05 OIF411 ");
val = hex2uint(px+ 2, 2); if (val < 0) return -1;
InstrNum = val & 0xFF;
fprintf(stdout, " No.%d ", InstrNum);
if (px[N] == 'I') {
ui16_t dw;
ui16_t sw;
char sn[9];
// 5.2 ID Data
//
N += 1;
strncpy(sn, px+4, 8); sn[8] = '\0';
val = hex2uint(px+12, 4); if (val < 0) return -1;
dw = val & 0xFFFF; // i16
val = hex2uint(px+16, 4); if (val < 0) return -1;
sw = val & 0xFFFF; // u8
fprintf(stdout, " SN:%s ", sn);
fprintf(stdout, " DW:%04X ", dw);
fprintf(stdout, " SW:%.2f ", sw/100.0);
// Diagnostics Word dw
// 0000 = "Default value, no diagnostics bits active"
// 0004 = "Ozone pump temperature below -5C"
// 0400 = "Ozone pump battery voltage (+VBatt) is not connected to OIF411"
// 0404 = 0004 | 0400
}
else {
ui32_t Icell;
ui16_t Ipump;
i16_t Tpump;
ui8_t InstrNum, Vbat, Vext;
// 5.1 Measurement Data
//
val = hex2uint(px+ 4, 4); if (val < 0) return -1;
Tpump = val & 0xFFFF; // i16
val = hex2uint(px+ 8, 5); if (val < 0) return -1;
Icell = val & 0xFFFFF; // u20
val = hex2uint(px+13, 2); if (val < 0) return -1;
Vbat = val & 0xFF; // u8
val = hex2uint(px+15, 3); if (val < 0) return -1;
Ipump = val & 0xFFF; // u12
val = hex2uint(px+18, 2); if (val < 0) return -1;
Vext = val & 0xFF; // u8
fprintf(stdout, " Tpump:%.2fC ", Tpump/100.0);
fprintf(stdout, " Icell:%.4fuA ", Icell/10000.0);
fprintf(stdout, " Vbat:%.1fV ", Vbat/10.0);
fprintf(stdout, " Ipump:%dmA ", Ipump);
fprintf(stdout, " Vext:%.1fV ", Vext/10.0);
}
}
else {
return -2;
}
return 0;
}
static int prn_aux_IDx08(char *xdata) {
// CFH Cryogenic Frost Point Hygrometer
// ID=0x08: CFH
// N=2*12 nibs
// 0 2 u8 Instrument_type = 0x08 (ID)
// 2 2 u8 Instrument_number
// 4 6 Tmir, Mirror Temperature
// 10 6 Vopt, Optics Voltage
// 16 4 Topt, Optics Temperature
// 20 4 Vbat, CFH Battery
//
char *px = xdata;
int N = 2*12;
int val;
ui8_t InstrNum;
if (*px) {
if (strncmp(px, "08", 2) != 0) {
px = strstr(xdata, "#08");
if (px == NULL) return -1;
else px += 1;
}
if (strlen(px) < N) return -1;
fprintf(stdout, " ID=0x08 CFH ");
val = hex2uint(px+ 2, 2); if (val < 0) return -1;
InstrNum = val & 0xFF;
fprintf(stdout, " No.%d ", InstrNum);
fprintf(stdout, " Tmir:0x%.6s ", px+4);
fprintf(stdout, " Vopt:0x%.6s ", px+10);
fprintf(stdout, " Topt:0x%.4s ", px+16);
fprintf(stdout, " Vbat:0x%.4s ", px+20);
}
else {
return -2;
}
return 0;
}
static int get_Aux(gpx_t *gpx, int out, int pos) {
//
// "Ozone Sounding with Vaisala Radiosonde RS41" user's guide
// "Ozone Sounding with Vaisala Radiosonde RS41" user's guide M211486EN
//
int auxlen, auxcrc, count7E, pos7E;
int i, n;
char *paux;
n = 0;
count7E = 0;
@ -1113,6 +1325,34 @@ static int get_Aux(gpx_t *gpx, int out, int pos) {
}
gpx->xdata[n] = '\0';
// decode OIF411 xdata
paux = gpx->xdata;
if (out && gpx->option.aux && *paux)
{
int val;
ui8_t ID;
for (i = 0; i < count7E; i++) {
if (paux > gpx->xdata) {
//while (paux < (gpx->xdata)+n && *paux != '#') paux++;
while (*paux && *paux != '#') paux++;
paux++;
}
if (strlen(paux) > 2) {
val = hex2uint(paux, 2);
if (val < 0) { paux += 2; continue; }
ID = val & 0xFF;
switch (ID) {
case 0x01: fprintf(stdout, "\n"); prn_aux_IDx01(paux); break;
case 0x05: fprintf(stdout, "\n"); prn_aux_IDx05(paux); break;
case 0x08: fprintf(stdout, "\n"); prn_aux_IDx08(paux); break;
}
paux++;
}
else break;
}
if ( !gpx->option.jsn ) fprintf(stdout, "\n");
}
i = check_CRC(gpx, pos, pck_ZERO); // 0x76xx: 00-padding block
if (i) gpx->crc |= crc_ZERO;
@ -1850,10 +2090,14 @@ static int print_position(gpx_t *gpx, int ec) {
}
// Include frequency derived from subframe information if available.
if (gpx->freq > 0){
if (gpx->freq > 0) {
fprintf(stdout, ", \"tx_frequency\": %d", gpx->freq );
}
// Reference time/position
fprintf(stdout, ", \"ref_datetime\": \"%s\"", "GPS" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
fprintf(stdout, ", \"ref_position\": \"%s\"", "GPS" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -2028,6 +2272,7 @@ int main(int argc, char *argv[]) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_bin = 0;
int option_softin = 0;
int option_pcmraw = 0;
@ -2094,9 +2339,10 @@ int main(int argc, char *argv[]) {
else if ( (strcmp(*argv, "-v") == 0) || (strcmp(*argv, "--verbose") == 0) ) {
gpx.option.vbs = 1;
}
else if (strcmp(*argv, "-vx") == 0) { gpx.option.vbs = 2; }
else if (strcmp(*argv, "-vx") == 0) { gpx.option.vbs = 2; } // xdata
else if (strcmp(*argv, "-vv") == 0) { gpx.option.vbs = 3; }
//else if (strcmp(*argv, "-vvv") == 0) { gpx.option.vbs = 4; }
else if (strcmp(*argv, "--aux") == 0) { gpx.option.aux = 1; }
else if (strcmp(*argv, "--crc") == 0) { gpx.option.crc = 1; }
else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
gpx.option.raw = 1;
@ -2147,16 +2393,18 @@ int main(int argc, char *argv[]) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 24.0) lpIQ_bw = bw*1e3;
option_lp = 1;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -2202,6 +2450,13 @@ int main(int argc, char *argv[]) {
}
if (!wavloaded) fp = stdin;
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
if (gpx.option.raw && gpx.option.jsn) gpx.option.slt = 1;
@ -2211,6 +2466,8 @@ int main(int argc, char *argv[]) {
rs_init_RS255(&gpx.RS); // RS, GF
}
if (gpx.option.aux) gpx.option.vbs = 2;
// init gpx
memcpy(gpx.frame, rs41_header_bytes, sizeof(rs41_header_bytes)); // 8 header bytes

Wyświetl plik

@ -1516,13 +1516,18 @@ static int print_position(gpx_t *gpx, int ec) { // GPS-Hoehe ueber Ellipsoid
if (gpx->jsn_freq > 0) { // rs92-frequency: gpx->freq
int fq_kHz = gpx->jsn_freq;
//if (gpx->freq > 0) fq_kHz = gpx->freq; // L-band: option.ngp ?
fprintf(stdout, ", \"freq\": %d", fq_kHz);
fprintf(stdout, ", \"freq\": %d", fq_kHz );
}
// Include frequency derived from subframe information if available.
if (gpx->freq > 0){
fprintf(stdout, ", \"tx_frequency\": %d", gpx->freq);
if (gpx->freq > 0) {
fprintf(stdout, ", \"tx_frequency\": %d", gpx->freq );
}
// Reference time/position
fprintf(stdout, ", \"ref_datetime\": \"%s\"", "GPS" ); // {"GPS", "UTC"} GPS-UTC=leap_sec
fprintf(stdout, ", \"ref_position\": \"%s\"", "GPS" ); // {"GPS", "MSL"} GPS=ellipsoid , MSL=geoid
#ifdef VER_JSN_STR
ver_jsn = VER_JSN_STR;
#endif
@ -1583,6 +1588,7 @@ int main(int argc, char *argv[]) {
int option_iqdc = 0;
int option_lp = 0;
int option_dc = 0;
int option_noLUT = 0;
int option_softin = 0;
int option_pcmraw = 0;
int sel_wavch = 0; // audio channel: left
@ -1778,16 +1784,18 @@ int main(int argc, char *argv[]) {
dsp.xlt_fq = -fq; // S(t) -> S(t)*exp(-f*2pi*I*t)
option_iq = 5;
}
else if (strcmp(*argv, "--lp") == 0) { option_lp = 1; } // IQ lowpass
else if (strcmp(*argv, "--lpIQ") == 0) { option_lp |= LP_IQ; } // IQ/IF lowpass
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
float bw = 0.0;
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6f && bw < 48.0f) set_lpIQbw = bw*1e3f;
option_lp = 1;
if (bw > 4.6 && bw < 48.0) set_lpIQbw = bw*1e3;
option_lp |= LP_IQ;
}
else if (strcmp(*argv, "--lpFM") == 0) { option_lp |= LP_FM; } // FM lowpass
else if (strcmp(*argv, "--dc") == 0) { option_dc = 1; }
else if (strcmp(*argv, "--noLUT") == 0) { option_noLUT = 1; }
else if (strcmp(*argv, "--min") == 0) {
option_min = 1;
}
@ -1845,6 +1853,13 @@ int main(int argc, char *argv[]) {
if (!option_der) gpx.gps.d_err = 1000;
}
if (option_iq == 5 && option_dc) option_lp |= LP_FM;
// LUT faster for decM, however frequency correction after decimation
// LUT recommonded if decM > 2
//
if (option_noLUT && option_iq == 5) dsp.opt_nolut = 1; else dsp.opt_nolut = 0;
gpx.option.crc = 1;
if (gpx.option.ecc < 2) gpx.option.ecc = 1; // turn off for ber-measurement