From d419b62a659f9dd23cf3ee7bbcbe2ce1c4fdcba8 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 31 May 2016 11:47:57 +0100 Subject: [PATCH] Always use phase enhancement; silently ignore --phase-enhance if given. --- debian/config-template | 3 -- debian/dump1090-mutability.config | 1 - debian/dump1090-mutability.postinst | 1 - debian/dump1090-mutability.templates | 7 ----- demod_2000.c | 4 +-- demod_2400.c | 45 ++-------------------------- dump1090.c | 3 +- dump1090.h | 1 - 8 files changed, 6 insertions(+), 59 deletions(-) diff --git a/debian/config-template b/debian/config-template index 203e3d5..77c23e2 100644 --- a/debian/config-template +++ b/debian/config-template @@ -34,9 +34,6 @@ PPM= # If yes, enable sampling at 2.4MHz. Otherwise, 2.0MHz is used. OVERSAMPLE= -# If yes, enables phase-enhancement of messages -PHASE_ENHANCE= - # # Decoding options # diff --git a/debian/dump1090-mutability.config b/debian/dump1090-mutability.config index af269a2..9c9ff0e 100644 --- a/debian/dump1090-mutability.config +++ b/debian/dump1090-mutability.config @@ -26,7 +26,6 @@ if [ -e $CONFIGFILE ]; then db_set_yn $NAME/rtlsdr-oversample "$OVERSAMPLE" db_set_yn $NAME/decode-fixcrc "$FIX_CRC" - db_set_yn $NAME/decode-phase-enhance "$PHASE_ENHANCE" db_set $NAME/decode-lat "$LAT" db_set $NAME/decode-lon "$LON" db_set $NAME/decode-max-range "$MAX_RANGE" diff --git a/debian/dump1090-mutability.postinst b/debian/dump1090-mutability.postinst index fd5dc96..614ba26 100644 --- a/debian/dump1090-mutability.postinst +++ b/debian/dump1090-mutability.postinst @@ -77,7 +77,6 @@ case "$1" in subvar rtlsdr-ppm PPM subvar_yn rtlsdr-oversample OVERSAMPLE subvar_yn decode-fixcrc FIX_CRC - subvar_yn decode-phase-enhance PHASE_ENHANCE subvar decode-lat LAT subvar decode-lon LON subvar decode-max-range MAX_RANGE diff --git a/debian/dump1090-mutability.templates b/debian/dump1090-mutability.templates index a7bd60a..ad2bc8a 100644 --- a/debian/dump1090-mutability.templates +++ b/debian/dump1090-mutability.templates @@ -69,13 +69,6 @@ Description: Fix detected CRC errors? Type: boolean Default: true -Template: dump1090-mutability/decode-phase-enhance -Description: Apply phase enhancement? - dump1090 can attempt to correct for messages that are received - out-of-phase from the sampling rate, at the expense of taking more CPU. -Type: boolean -Default: true - Template: dump1090-mutability/decode-lat Description: Latitude of receiver, in decimal degrees: If the location of the receiver is provided, dump1090 can do diff --git a/demod_2000.c b/demod_2000.c index 493052e..a083806 100644 --- a/demod_2000.c +++ b/demod_2000.c @@ -880,8 +880,8 @@ void demodulate2000(struct mag_buf *mag) { } } - // Retry with phase correction if enabled, necessary and possible. - if (Modes.phase_enhance && (!message_ok || mm.correctedbits > 0) && !use_correction && j && detectOutOfPhase(pPreamble)) { + // Retry with phase correction if necessary and possible. + if ((!message_ok || mm.correctedbits > 0) && !use_correction && j && detectOutOfPhase(pPreamble)) { use_correction = 1; j--; } else { use_correction = 0; diff --git a/demod_2400.c b/demod_2400.c index e1b2096..56aa7ae 100644 --- a/demod_2400.c +++ b/demod_2400.c @@ -118,33 +118,6 @@ static inline int correlate_check_4(uint16_t *m) { abs(correlate_phase2(&m[10])); } -// Work out the best phase offset to use for the given message. -static int best_phase(uint16_t *m) { - int test; - int best = -1; - int bestval = (m[0] + m[1] + m[2] + m[3] + m[4] + m[5]); // minimum correlation quality we will accept - - // empirical testing suggests that 4..8 is the best range to test for here - // (testing a wider range runs the danger of picking the wrong phase for - // a message that would otherwise be successfully decoded - the correlation - // functions can match well with a one symbol / half bit offset) - - // this is consistent with the peak detection which should produce - // the first data symbol with phase offset 4..8 - - test = correlate_check_4(&m[0]); - if (test > bestval) { bestval = test; best = 4; } - test = correlate_check_0(&m[1]); - if (test > bestval) { bestval = test; best = 5; } - test = correlate_check_1(&m[1]); - if (test > bestval) { bestval = test; best = 6; } - test = correlate_check_2(&m[1]); - if (test > bestval) { bestval = test; best = 7; } - test = correlate_check_3(&m[1]); - if (test > bestval) { bestval = test; best = 8; } - return best; -} - // // Given 'mlen' magnitude samples in 'm', sampled at 2.4MHz, // try to demodulate some Mode S messages. @@ -170,7 +143,7 @@ void demodulate2400(struct mag_buf *mag) uint16_t *preamble = &m[j]; int high; uint32_t base_signal, base_noise; - int initial_phase, first_phase, last_phase, try_phase; + int try_phase; int msglen; // Look for a message starting at around sample 0 with phase offset 3..7 @@ -252,22 +225,10 @@ void demodulate2400(struct mag_buf *mag) continue; } - if (Modes.phase_enhance) { - first_phase = 4; - last_phase = 8; // try all phases - } else { - // Crosscorrelate against the first few bits to find a likely phase offset - initial_phase = best_phase(&preamble[19]); - if (initial_phase < 0) { - continue; // nothing satisfactory - } - - first_phase = last_phase = initial_phase; // try only the phase we think it is - } - + // try all phases Modes.stats_current.demod_preambles++; bestmsg = NULL; bestscore = -2; bestphase = -1; - for (try_phase = first_phase; try_phase <= last_phase; ++try_phase) { + for (try_phase = 4; try_phase <= 8; ++try_phase) { uint16_t *pPtr; int phase, i, score, bytelen; diff --git a/dump1090.c b/dump1090.c index a35e4e1..0bc4407 100644 --- a/dump1090.c +++ b/dump1090.c @@ -702,7 +702,6 @@ void showHelp(void) { "--fix Enable single-bits error correction using CRC\n" "--no-fix Disable single-bits error correction using CRC\n" "--no-crc-check Disable messages with broken CRC (discouraged)\n" -"--phase-enhance Enable phase enhancement\n" #ifdef ALLOW_AGGRESSIVE "--aggressive More CPU for more messages (two bits fixes, ...)\n" #endif @@ -964,7 +963,7 @@ int main(int argc, char **argv) { } else if (!strcmp(argv[j],"--no-crc-check")) { Modes.check_crc = 0; } else if (!strcmp(argv[j],"--phase-enhance")) { - Modes.phase_enhance = 1; + // Ignored, always enabled } else if (!strcmp(argv[j],"--raw")) { Modes.raw = 1; } else if (!strcmp(argv[j],"--net")) { diff --git a/dump1090.h b/dump1090.h index d4bbb37..efd2e1d 100644 --- a/dump1090.h +++ b/dump1090.h @@ -282,7 +282,6 @@ struct { // Internal state // Configuration char *filename; // Input form file, --ifile option int oversample; - int phase_enhance; // Enable phase enhancement if true int nfix_crc; // Number of crc bit error(s) to correct int check_crc; // Only display messages with good CRC int raw; // Raw output format