From 796580e1620246806069f91e61a93e147ea66547 Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Sun, 24 Jan 2021 22:18:20 +1030 Subject: [PATCH] Initial working iMet54 decoding. --- auto_rx/auto_rx.py | 2 +- auto_rx/autorx/config.py | 2 +- auto_rx/autorx/decode.py | 12 +++++++++--- demod/mod/imet54mod.c | 21 +++++++++++++++++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/auto_rx/auto_rx.py b/auto_rx/auto_rx.py index 07fd7d1..1f8dd04 100644 --- a/auto_rx/auto_rx.py +++ b/auto_rx/auto_rx.py @@ -642,7 +642,7 @@ def main(): "--type", type=str, default=None, - help="Immediately start a decoder for a provided sonde type (Valid Types: RS41, RS92, DFM, M10, M20, IMET, IMET54, LMS6, MK2LMS, MEISEI)", + help="Immediately start a decoder for a provided sonde type (Valid Types: RS41, RS92, DFM, M10, M20, IMET, IMET5, LMS6, MK2LMS, MEISEI)", ) parser.add_argument( "-t", diff --git a/auto_rx/autorx/config.py b/auto_rx/autorx/config.py index 080ee5e..b000a8f 100644 --- a/auto_rx/autorx/config.py +++ b/auto_rx/autorx/config.py @@ -383,7 +383,7 @@ def read_auto_rx_config(filename, no_sdr_test=False): "M10": True, "M20": True, "IMET": False, - "IMET54": False, + "IMET5": False, "LMS6": True, "MK2LMS": False, "MEISEI": False, diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index 639beb5..4d5f524 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -28,7 +28,7 @@ VALID_SONDE_TYPES = [ "M10", "M20", "IMET", - "IMET54", + "IMET5", "MK2LMS", "LMS6", "MEISEI", @@ -97,7 +97,7 @@ class SondeDecoder(object): "M10", "M20", "IMET", - "IMET54", + "IMET5", "MK2LMS", "LMS6", "MEISEI", @@ -454,7 +454,7 @@ class SondeDecoder(object): # iMet-4 (IMET1RS) decoder decode_cmd += "./imet1rs_dft --json 2>/dev/null" - elif self.sonde_type == "IMET54": + elif self.sonde_type == "IMET5": # iMet-4 Sondes decode_cmd = "%s %s-p %d -d %s %s-M raw -F9 -s 48k -f %d 2>/dev/null |" % ( @@ -1129,6 +1129,12 @@ class SondeDecoder(object): _telemetry["id"] = self.imet_id _telemetry["station_code"] = self.imet_location + # iMet-54 Specific Actions + if self.sonde_type == "IMET5": + # Fix up the time. + _telemetry["datetime_dt"] = fix_datetime(_telemetry["datetime"]) + + # LMS Specific Actions (LMS6, MK2LMS) if "LMS" in self.sonde_type: # We are only provided with HH:MM:SS, so the timestamp needs to be fixed, just like with the iMet sondes diff --git a/demod/mod/imet54mod.c b/demod/mod/imet54mod.c index 7298899..40e9cb8 100644 --- a/demod/mod/imet54mod.c +++ b/demod/mod/imet54mod.c @@ -299,8 +299,10 @@ static int print_position(gpx_t *gpx, int ecc, int ecc_gps) { } if (gpx->option.jsn && ecc >= 0) { // ecc_gps >= 0 not reliable? + 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, ", \"id\": \"%u\", \"datetime\": \"%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f", + fprintf(stdout, ", \"frame\": %lu", count_day); + fprintf(stdout, ", \"id\": \"IMET54-%u\", \"datetime\": \"%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f", gpx->SNu32, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt); //fprintf(stdout, ", \"subtype\": \"%s\"", "IMET54"); if (gpx->jsn_freq > 0) { @@ -401,6 +403,8 @@ int main(int argc, char *argv[]) { int rawhex = 0; int cfreq = -1; + float baudrate = -1; + FILE *fp; char *fpname = NULL; @@ -486,6 +490,14 @@ int main(int argc, char *argv[]) { } else return -1; } + else if ( (strcmp(*argv, "--br") == 0) ) { + ++argv; + if (*argv) { + baudrate = atof(*argv); + if (baudrate < 4600 || baudrate > 5000) baudrate = BAUD_RATE; // default: 4798 + } + else return -1; + } else if (strcmp(*argv, "--iq0") == 0) { option_iq = 1; } // differential/FM-demod else if (strcmp(*argv, "--iq2") == 0) { option_iq = 2; } else if (strcmp(*argv, "--iq3") == 0) { option_iq = 3; } // iq2==iq3 @@ -619,10 +631,15 @@ int main(int argc, char *argv[]) { dsp.opt_dc = option_dc; dsp.opt_IFmin = option_min; - if ( dsp.sps < 8 ) { + if ( dsp.sps < 5 ) { fprintf(stderr, "note: sample rate low (%.1f sps)\n", dsp.sps); } + if (baudrate > 0) { + dsp.br = (float)baudrate; + dsp.sps = (float)dsp.sr/dsp.br; + fprintf(stderr, "sps corr: %.4f\n", dsp.sps); + } k = init_buffers(&dsp); // BT=0.5 (IQ-Int: BT > 0.5 ?) if ( k < 0 ) {