From efe9918536aea9d9afb56c816f6cb9b89cfaab35 Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Fri, 23 Aug 2024 18:51:04 +0930 Subject: [PATCH 1/2] Rebase all mod demodulators --- auto_rx/autorx/__init__.py | 2 +- demod/mod/demod_mod.c | 18 ++++--- demod/mod/demod_mod.h | 4 +- demod/mod/dfm09mod.c | 9 ++-- demod/mod/imet54mod.c | 103 ++++++++++++++++++++++++++----------- demod/mod/lms6Xmod.c | 10 ++-- demod/mod/m10mod.c | 11 ++-- demod/mod/meisei100mod.c | 7 +-- demod/mod/mp3h1mod.c | 9 ++-- demod/mod/mts01mod.c | 7 +-- demod/mod/rs41mod.c | 7 +-- demod/mod/rs92mod.c | 9 ++-- 12 files changed, 125 insertions(+), 71 deletions(-) diff --git a/auto_rx/autorx/__init__.py b/auto_rx/autorx/__init__.py index 551ded58..6fe551d4 100644 --- a/auto_rx/autorx/__init__.py +++ b/auto_rx/autorx/__init__.py @@ -12,7 +12,7 @@ # MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus. # PATCH - Small changes, or minor feature additions. -__version__ = "1.7.5-beta2" +__version__ = "1.7.5-beta3" # Global Variables diff --git a/demod/mod/demod_mod.c b/demod/mod/demod_mod.c index 38d8f5c7..3d715e8e 100644 --- a/demod/mod/demod_mod.c +++ b/demod/mod/demod_mod.c @@ -918,18 +918,20 @@ static int headcmp(dsp_t *dsp, int opt_dc) { //if (opt_dc == 0 || dsp->opt_iq > 1) dsp->dc = 0; - if (dsp->symhd != 1) step = 2; + if (dsp->symhd != 1) step = 2; // step == symhd if (inv) sign=1; for (pos = 0; pos < len; pos++) { // L = dsp->hdrlen * dsp->sps + 0.5; //read_bufbit(dsp, dsp->symhd, dsp->rawbits+pos*step, mvp+1-(int)(len*dsp->sps), pos); read_bufbit(dsp, dsp->symhd, dsp->rawbits+pos*step, dsp->mv_pos+1-dsp->L, pos); } + + pos = len*step; // == hdrlen dsp->rawbits[pos] = '\0'; - while (len > 0) { - if ((dsp->rawbits[len-1]^sign) != dsp->hdr[len-1]) errs += 1; - len--; + while (pos > 0) { + if ((dsp->rawbits[pos-1]^sign) != dsp->hdr[pos-1]) errs += 1; + pos--; } return errs; @@ -1713,7 +1715,7 @@ static float corr_softhdb(hdb_t *hdb) { // max score in window probably not need return sum; } -int f32soft_read(FILE *fp, float *s) { +int f32soft_read(FILE *fp, float *s, int inv) { unsigned int word = 0; short *b = (short*)&word; float *f = (float*)&word; @@ -1730,17 +1732,19 @@ int f32soft_read(FILE *fp, float *s) { if (bps == 16) { *s /= 256.0; } } + if (inv) *s = -*s; + return 0; } -int find_softbinhead(FILE *fp, hdb_t *hdb, float *score) { +int find_softbinhead(FILE *fp, hdb_t *hdb, float *score, int inv) { int headlen = hdb->len; float sbit; float mv; //*score = 0.0; - while ( f32soft_read(fp, &sbit) != EOF ) + while ( f32soft_read(fp, &sbit, inv) != EOF ) { hdb->bufpos = (hdb->bufpos+1) % headlen; hdb->sbuf[hdb->bufpos] = sbit; diff --git a/demod/mod/demod_mod.h b/demod/mod/demod_mod.h index aa2cc731..685fe234 100644 --- a/demod/mod/demod_mod.h +++ b/demod/mod/demod_mod.h @@ -187,8 +187,8 @@ int free_buffers(dsp_t *); int find_header(dsp_t *, float, int, int, int); -int f32soft_read(FILE *fp, float *s); +int f32soft_read(FILE *fp, float *s, int inv); int find_binhead(FILE *fp, hdb_t *hdb, float *score); -int find_softbinhead(FILE *fp, hdb_t *hdb, float *score); +int find_softbinhead(FILE *fp, hdb_t *hdb, float *score, int inv); diff --git a/demod/mod/dfm09mod.c b/demod/mod/dfm09mod.c index e248b491..355fe0b5 100644 --- a/demod/mod/dfm09mod.c +++ b/demod/mod/dfm09mod.c @@ -1376,7 +1376,8 @@ int main(int argc, char **argv) { } else if (strcmp(*argv, "--auto") == 0) { option_auto = 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--dist") == 0) { option_dist = 1; option_ecc = 1; } else if (strcmp(*argv, "--json") == 0) { option_json = 1; option_ecc = 1; } else if (strcmp(*argv, "--jsn_cfq") == 0) { @@ -1628,7 +1629,7 @@ int main(int argc, char **argv) { hdrcnt += nfrms; } else if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); hdrcnt += nfrms; } else { //2 (false positive) // FM-audio: @@ -1677,9 +1678,9 @@ int main(int argc, char **argv) { float s1 = 0.0; float s2 = 0.0; float s = 0.0; - bitQ = f32soft_read(fp, &s1); + bitQ = f32soft_read(fp, &s1, option_softin == 2); if (bitQ != EOF) { - bitQ = f32soft_read(fp, &s2); + bitQ = f32soft_read(fp, &s2, option_softin == 2); if (bitQ != EOF) { s = s2-s1; // integrate both symbols // only 2nd Manchester symbol: s2 hsbit.sb = s; diff --git a/demod/mod/imet54mod.c b/demod/mod/imet54mod.c index 8225df24..9212c611 100644 --- a/demod/mod/imet54mod.c +++ b/demod/mod/imet54mod.c @@ -283,6 +283,26 @@ static int crc32ok(ui8_t *bytes, int len) { return 0; } +static ui32_t crc32_802(ui8_t *msg, int len) { + ui32_t poly32 = 0x04C11DB7; // CRC32 802-3 (Ethernet) normal + ui32_t rem = 0x0; + ui32_t out = 0x63D60875; + ui32_t crc = 0; + int i, j; + for (i = 0; i < len; i++) { + rem ^= (msg[i] << 24); + for (j = 0; j < 8; j++) { + if (rem & (1 << 31)) { + rem = (rem << 1) ^ poly32; + } + else { + rem <<= 1; + } + } + } + return rem ^ out; +} + /* ------------------------------------------------------------------------------------ */ static ui32_t u4be(ui8_t *bytes) { // 32bit unsigned int @@ -324,6 +344,21 @@ static ui16_t u2be(ui8_t *bytes) { // 16bit unsigned int #define pos_F8 0x52 // 1 byte #define pos_CNT11 0x5E // 1 byte +#define pos_CRC32CONT 0x34 // 4 byte + + +static int crc32ok_cont(ui8_t *bytes) { + ui8_t m4[pos_CRC32CONT] = {0}; + ui32_t crc32dat = u4be(bytes+pos_CRC32CONT); + ui32_t crc32val = 0; + int i, j; + for (i = 0; i < pos_CRC32CONT/4; i++) { + for (j = 0; j < 4; j++) m4[4*i+j] = bytes[4*i+3-j]; + } + crc32val = crc32_802(m4, pos_CRC32CONT); + return crc32val == crc32dat; +} + static int get_SN(gpx_t *gpx) { gpx->SNu32 = u4be(gpx->frame+pos_SN); @@ -456,21 +491,19 @@ static int reset_gpx(gpx_t *gpx) { /* ------------------------------------------------------------------------------------ */ -static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps, int ecc_std) { +static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_tlm, int ecc_std) { int prnGPS = 0, prnPTU = 0, prnSTS = 0; int ptu1e9 = 0; int tp_err = 0; - int pos_ok = 0, - frm_ok = 0, + int frm_ok = 0, crc_ok = 0, std_ok = 0; int rs_type = 54; crc_ok = crc32ok(gpx->frame, len); - pos_ok = (ecc_frm >= 0 && len > pos_STATUS+2); frm_ok = (ecc_frm >= 0 && len > pos_F8); reset_gpx(gpx); @@ -520,16 +553,15 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps, int ecc } if ( crc_ok ) fprintf(stdout, " [OK]"); // std frame: frame[104..105]==0x4000 ? - else { - if (gpx->frame[pos_F8] == 0xF8) fprintf(stdout, " [NO]"); - else if ( ecc_std == 0 ) { // full frame: pos_F8_full==pos_F8_std+11 ? - fprintf(stdout, " [ok]"); + else { // continuous frame: pos_F8_full==pos_F8_std+11 ? + crc_ok = crc32ok_cont(gpx->frame); + if ( crc_ok ) fprintf(stdout, " [ok]"); + else if ( ecc_std == 0 ) { + fprintf(stdout, " [oo]"); std_ok = 1; } - else { - fprintf(stdout, " [no]"); - std_ok = 0; - } + else if (gpx->frame[pos_F8] == 0xF8) fprintf(stdout, " [NO]"); + else fprintf(stdout, " [no]"); } // (imet54:GPS+PTU) status: 003E , (imet50:GPS); 0030 @@ -540,7 +572,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps, int ecc // error correction if (gpx->option.ecc && ecc_frm != 0) { fprintf(stdout, " # (%d)", ecc_frm); - if (gpx->option.vbs) fprintf(stdout, " [%d]", ecc_gps); + if (gpx->option.vbs) fprintf(stdout, " [%d]", ecc_tlm); } fprintf(stdout, "\n"); @@ -549,7 +581,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps, int ecc // prnGPS,prnTPU if (gpx->option.jsn && frm_ok && (crc_ok || std_ok) && (gpx->status&0x30)==0x30) { char *ver_jsn = NULL; - 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); @@ -586,6 +618,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps, int ecc static void print_frame(gpx_t *gpx, int len, int b2B) { int i, j; int ecc_frm = 0, ecc_gps = 0, ecc_std = 0; + int ecc_tlm = 0; ui8_t bits8n1[BITFRAME_LEN+10]; // (RAW)BITFRAME_LEN ui8_t bits[BITFRAME_LEN]; // 8/10 (RAW)BITFRAME_LEN ui8_t nib[FRAME_LEN]; @@ -613,15 +646,17 @@ static void print_frame(gpx_t *gpx, int len, int b2B) { ecc_frm = 0; ecc_gps = 0; + ecc_tlm = 0; ecc_std = 0; - for (j = 0; j < len/8; j++) { // alt. only GPS block + for (j = 0; j < 2*pos_CRC32CONT; j++) { // alt. only GPS block // len/8 ecc_frm += ec[j]; if (ec[j] > 0x10) ecc_frm = -1; - if (j < pos_GPSalt+4+8) ecc_gps = ecc_frm; - if (j < 2*FRMBYTE_STD) ecc_std = ecc_frm; + if (j < 2*(pos_GPSalt+4)) ecc_gps = ecc_frm; + if (j < 2*(pos_STATUS+2)) ecc_tlm = ecc_frm; + if (j < 2*pos_CRC32CONT) ecc_std = ecc_frm; // pos_STATUS < pos_CRC32CONT < FRMBYTE_STD if (ecc_frm < 0) break; } - if (j < 2*FRMBYTE_STD) ecc_std = -1; + if (j < 2*pos_CRC32CONT) ecc_std = -1; } else { ecc_frm = -2; // TODO: parse ecc-info from raw file @@ -630,7 +665,7 @@ static void print_frame(gpx_t *gpx, int len, int b2B) { if (gpx->option.raw) { - int crc_ok = crc32ok(gpx->frame, len); + int crc_ok = crc32ok(gpx->frame, len/16); for (i = 0; i < len/16; i++) { fprintf(stdout, "%02X", gpx->frame[i]); @@ -642,24 +677,31 @@ static void print_frame(gpx_t *gpx, int len, int b2B) { } if ( crc_ok ) fprintf(stdout, " [OK]"); // std frame: frame[104..105]==0x4000 ? - else { - if (gpx->frame[pos_F8] == 0xF8) fprintf(stdout, " [NO]"); // full frame: pos_F8_full==pos_F8_std+11 ? - else if ( ecc_std == 0 ) fprintf(stdout, " [ok]"); - else fprintf(stdout, " [no]"); + else { // continuous frame: pos_F8_full==pos_F8_std+11 ? + crc_ok = crc32ok_cont(gpx->frame); + if ( crc_ok ) fprintf(stdout, " [ok]"); + else if ( ecc_std == 0 ) { + fprintf(stdout, " [oo]"); + } + else if (gpx->frame[pos_F8] == 0xF8) fprintf(stdout, " [NO]"); + else fprintf(stdout, " [no]"); } + // [ok] # (-1): + // CRC32 more reliable than CRC16 + // ecc_frm=-1 => errors in parity only ? (JSON output only if crc_ok and ecc_frm >= 0) if (gpx->option.ecc && ecc_frm != 0) { fprintf(stdout, " # (%d)", ecc_frm); - fprintf(stdout, " [%d]", ecc_gps); + fprintf(stdout, " [%d]", ecc_tlm); } fprintf(stdout, "\n"); if (gpx->option.slt /*&& gpx->option.jsn*/) { - print_position(gpx, len/16, ecc_frm, ecc_gps, ecc_std); + print_position(gpx, len/16, ecc_frm, ecc_tlm, ecc_std); } } else { - print_position(gpx, len/16, ecc_frm, ecc_gps, ecc_std); + print_position(gpx, len/16, ecc_frm, ecc_tlm, ecc_std); } } @@ -752,7 +794,8 @@ int main(int argc, char *argv[]) { 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--ths") == 0) { ++argv; if (*argv) { @@ -964,7 +1007,7 @@ int main(int argc, char *argv[]) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 4, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -987,7 +1030,7 @@ int main(int argc, char *argv[]) { { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); if (bitQ != EOF) { bit = (s>=0.0); hsbit.hb = bit; @@ -1023,7 +1066,7 @@ int main(int argc, char *argv[]) { while ( 0 && bitpos < 4*BITFRAME_LEN/3 ) { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); } else { bitQ = read_slbit(&dsp, &bit, 0, bitofs, bitpos, -1, 0); // symlen=1 diff --git a/demod/mod/lms6Xmod.c b/demod/mod/lms6Xmod.c index f16f7b4a..3483193c 100644 --- a/demod/mod/lms6Xmod.c +++ b/demod/mod/lms6Xmod.c @@ -789,7 +789,6 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) { if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn); printf(" }\n"); printf("\n"); - fflush(stdout); } } @@ -920,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; @@ -1104,7 +1103,8 @@ int main(int argc, char **argv) { option_inv = 1; // nicht noetig } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--ths") == 0) { ++argv; if (*argv) { @@ -1352,7 +1352,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 10, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -1383,7 +1383,7 @@ int main(int argc, char **argv) { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); if (bitQ != EOF) { rhsbit.sb = s; rhsbit.hb = (s>=0.0); diff --git a/demod/mod/m10mod.c b/demod/mod/m10mod.c index ec2a686d..0d70ae02 100644 --- a/demod/mod/m10mod.c +++ b/demod/mod/m10mod.c @@ -1232,7 +1232,8 @@ 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; } else if (strcmp(*argv, "--ths") == 0) { ++argv; @@ -1429,7 +1430,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 2, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -1456,9 +1457,9 @@ int main(int argc, char **argv) { float s1 = 0.0; float s2 = 0.0; float s = 0.0; - bitQ = f32soft_read(fp, &s1); + bitQ = f32soft_read(fp, &s1, option_softin == 2); if (bitQ != EOF) { - bitQ = f32soft_read(fp, &s2); + bitQ = f32soft_read(fp, &s2, option_softin == 2); if (bitQ != EOF) { s = s2-s1; // integrate both symbols // only 2nd Manchester symbol: s2 bit = (s>=0.0); // no soft decoding @@ -1495,7 +1496,7 @@ int main(int argc, char **argv) { while ( bitpos < 5*BITFRAME_LEN ) { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); } else { bitQ = read_slbit(&dsp, &bit, 0, bitofs, bitpos, -1, 0); // symlen=2 diff --git a/demod/mod/meisei100mod.c b/demod/mod/meisei100mod.c index 923c14cd..cf6f40c0 100644 --- a/demod/mod/meisei100mod.c +++ b/demod/mod/meisei100mod.c @@ -468,7 +468,8 @@ int main(int argc, char **argv) { else return -1; } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--ths") == 0) { ++argv; if (*argv) { @@ -684,7 +685,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 1, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -704,7 +705,7 @@ int main(int argc, char **argv) { while (bitpos < RAWBITFRAME_LEN/2-RAWHEADLEN) { // 2*600-48 if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); if (bitQ != EOF) bit = (s>=0.0); // no soft decoding } else { diff --git a/demod/mod/mp3h1mod.c b/demod/mod/mp3h1mod.c index 5c7caf1c..f610495e 100644 --- a/demod/mod/mp3h1mod.c +++ b/demod/mod/mp3h1mod.c @@ -967,7 +967,8 @@ int main(int argc, char **argv) { gpx.option.ptu = 1; } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "-d") == 0) { ++argv; if (*argv) { @@ -1174,7 +1175,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 2, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -1200,9 +1201,9 @@ int main(int argc, char **argv) { float s1 = 0.0; float s2 = 0.0; float s = 0.0; - bitQ = f32soft_read(fp, &s1); + bitQ = f32soft_read(fp, &s1, option_softin == 2); if (bitQ != EOF) { - bitQ = f32soft_read(fp, &s2); + bitQ = f32soft_read(fp, &s2, option_softin == 2); if (bitQ != EOF) { s = s2-s1; // integrate both symbols // Manchester2=s2 (invert to Manchester1=s1 below) bit = (s>=0.0); // no soft decoding diff --git a/demod/mod/mts01mod.c b/demod/mod/mts01mod.c index 75a75db9..0af8a064 100644 --- a/demod/mod/mts01mod.c +++ b/demod/mod/mts01mod.c @@ -371,7 +371,8 @@ int main(int argc, char **argv) { spike = 1; } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--ths") == 0) { ++argv; if (*argv) { @@ -565,7 +566,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 2, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -588,7 +589,7 @@ int main(int argc, char **argv) { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); if (bitQ != EOF) { bit = (s>=0.0); hsbit.hb = bit; diff --git a/demod/mod/rs41mod.c b/demod/mod/rs41mod.c index 937f7ed1..dfe19b9f 100644 --- a/demod/mod/rs41mod.c +++ b/demod/mod/rs41mod.c @@ -2439,7 +2439,8 @@ int main(int argc, char *argv[]) { 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; } else if (strcmp(*argv, "--ths") == 0) { ++argv; @@ -2662,7 +2663,7 @@ int main(int argc, char *argv[]) { header_found = find_binhead(fp, &hdb, &_mv); } else if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 4, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -2695,7 +2696,7 @@ int main(int argc, char *argv[]) { } else if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); if (bitQ != EOF) { bit = (s>=0.0); hsbit.hb = bit; diff --git a/demod/mod/rs92mod.c b/demod/mod/rs92mod.c index 39e6ad2b..797a218f 100644 --- a/demod/mod/rs92mod.c +++ b/demod/mod/rs92mod.c @@ -1753,7 +1753,8 @@ int main(int argc, char *argv[]) { } else if (strcmp(*argv, "--spike") == 0) { spike = 1; } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--ths") == 0) { ++argv; if (*argv) { @@ -1985,7 +1986,7 @@ int main(int argc, char *argv[]) { { if (option_softin) { for (k = 0; k < hdb.len; k++) hdb.sbuf[k] = 0.0; - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { header_found = find_header(&dsp, thres, 3, bitofs, dsp.opt_dc); @@ -2012,9 +2013,9 @@ int main(int argc, char *argv[]) { float s1 = 0.0; float s2 = 0.0; float s = 0.0; - bitQ = f32soft_read(fp, &s1); + bitQ = f32soft_read(fp, &s1, option_softin == 2); if (bitQ != EOF) { - bitQ = f32soft_read(fp, &s2); + bitQ = f32soft_read(fp, &s2, option_softin == 2); if (bitQ != EOF) { s = s2-s1; // integrate both symbols // only 2nd Manchester symbol: s2 bit = (s>=0.0); // no soft decoding From a86f2102ee4a0cc8069bfaeabda12509017c5a1c Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Fri, 23 Aug 2024 18:55:22 +0930 Subject: [PATCH 2/2] Rebase m20mod --- demod/mod/m20mod.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/demod/mod/m20mod.c b/demod/mod/m20mod.c index 2802e043..c663bed2 100644 --- a/demod/mod/m20mod.c +++ b/demod/mod/m20mod.c @@ -1098,7 +1098,8 @@ int main(int argc, char **argv) { spike = 1; } 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, "--softin") == 0) { option_softin = 1; } // float32 soft input + else if (strcmp(*argv, "--softinv") == 0) { option_softin = 2; } // float32 inverted soft input else if (strcmp(*argv, "--silent") == 0) { gpx.option.slt = 1; } else if (strcmp(*argv, "--ths") == 0) { ++argv; @@ -1301,7 +1302,7 @@ int main(int argc, char **argv) { while ( 1 ) { if (option_softin) { - header_found = find_softbinhead(fp, &hdb, &_mv); + header_found = find_softbinhead(fp, &hdb, &_mv, option_softin == 2); } else { // FM-audio: header_found = find_header(&dsp, thres, 2, bitofs, dsp.opt_dc); // optional 2nd pass: dc=0 @@ -1328,9 +1329,9 @@ int main(int argc, char **argv) { float s1 = 0.0; float s2 = 0.0; float s = 0.0; - bitQ = f32soft_read(fp, &s1); + bitQ = f32soft_read(fp, &s1, option_softin == 2); if (bitQ != EOF) { - bitQ = f32soft_read(fp, &s2); + bitQ = f32soft_read(fp, &s2, option_softin == 2); if (bitQ != EOF) { s = s2-s1; // integrate both symbols // only 2nd Manchester symbol: s2 bit = (s>=0.0); // no soft decoding @@ -1364,7 +1365,7 @@ int main(int argc, char **argv) { while ( bitpos < 5*BITFRAME_LEN ) { if (option_softin) { float s = 0.0; - bitQ = f32soft_read(fp, &s); + bitQ = f32soft_read(fp, &s, option_softin == 2); } else { bitQ = read_slbit(&dsp, &bit, 0, bitofs, bitpos, -1, 0); // symlen=2