From 977493cf6323bb9e2e17aee3856e020783d436b9 Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 26 Jan 2013 13:03:24 +0100 Subject: [PATCH] Strong preamble detection even with --aggressive. To try to decode messages with a fundamentally flawed preamble is mostly a useless waste of CPU time. The new aggressive mode still detects a sensible percentage of additional messages because of the error tolerance and two-bits fixes but does not waste your CPU time. --- README.md | 1 - dump1090.c | 60 ++++++++++++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 87e9b96..8a9f752 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,6 @@ sending DF17 packets), but can detect a few more messages. The algorithm in aggressive mode is modified in the following ways: -* Preamble detection is weakened to be more liberal in what is consdered valid. * Up to two demodulation errors are tolerated (adjacent entires in the magnitude vector with the same eight). Normally only messages without errors are checked. diff --git a/dump1090.c b/dump1090.c index 9990aef..c3a6f6f 100644 --- a/dump1090.c +++ b/dump1090.c @@ -1361,38 +1361,36 @@ void detectModeS(uint16_t *m, uint32_t mlen) { continue; } - if (!Modes.aggressive) { - /* The samples between the two spikes must be < than the average - * of the high spikes level. We don't test bits too near to - * the high levels as signals can be out of phase so part of the - * energy can be in the near samples. */ - high = (m[j]+m[j+2]+m[j+7]+m[j+9])/6; - if (m[j+4] >= high || - m[j+5] >= high) - { - if (Modes.debug & MODES_DEBUG_NOPREAMBLE && - m[j] > MODES_DEBUG_NOPREAMBLE_LEVEL) - dumpRawMessage( - "Too high level in samples between 3 and 6", - msg, m, j); - continue; - } + /* The samples between the two spikes must be < than the average + * of the high spikes level. We don't test bits too near to + * the high levels as signals can be out of phase so part of the + * energy can be in the near samples. */ + high = (m[j]+m[j+2]+m[j+7]+m[j+9])/6; + if (m[j+4] >= high || + m[j+5] >= high) + { + if (Modes.debug & MODES_DEBUG_NOPREAMBLE && + m[j] > MODES_DEBUG_NOPREAMBLE_LEVEL) + dumpRawMessage( + "Too high level in samples between 3 and 6", + msg, m, j); + continue; + } - /* Similarly samples in the range 11-14 must be low, as it is the - * space between the preamble and real data. Again we don't test - * bits too near to high levels, see above. */ - if (m[j+11] >= high || - m[j+12] >= high || - m[j+13] >= high || - m[j+14] >= high) - { - if (Modes.debug & MODES_DEBUG_NOPREAMBLE && - m[j] > MODES_DEBUG_NOPREAMBLE_LEVEL) - dumpRawMessage( - "Too high level in samples between 10 and 15", - msg, m, j); - continue; - } + /* Similarly samples in the range 11-14 must be low, as it is the + * space between the preamble and real data. Again we don't test + * bits too near to high levels, see above. */ + if (m[j+11] >= high || + m[j+12] >= high || + m[j+13] >= high || + m[j+14] >= high) + { + if (Modes.debug & MODES_DEBUG_NOPREAMBLE && + m[j] > MODES_DEBUG_NOPREAMBLE_LEVEL) + dumpRawMessage( + "Too high level in samples between 10 and 15", + msg, m, j); + continue; } Modes.stat_valid_preamble++;