From f24699f14eaccc850562756a7d98322ab998fc64 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Wed, 19 Oct 2022 08:29:53 +0200 Subject: [PATCH] Fixed bug in M17 demodulator causing it to sometimes take more than 20ms to process a block of baseband samples when, in unlocked state, a valid syncword is searched. --- openrtx/src/protocols/M17/M17Demodulator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openrtx/src/protocols/M17/M17Demodulator.cpp b/openrtx/src/protocols/M17/M17Demodulator.cpp index 66b839d5..61df2c79 100644 --- a/openrtx/src/protocols/M17/M17Demodulator.cpp +++ b/openrtx/src/protocols/M17/M17Demodulator.cpp @@ -523,10 +523,15 @@ bool M17Demodulator::update() if ((hammingSync > maxHamming) && (hammingLsf > maxHamming)) { - // Lock lost + // Lock lost, reset demodulator alignment (phase) only + // if we were locked on a valid signal. + // This to avoid, in case of absence of carrier, to fall + // in a loop where the demodulator continues to search + // for the syncword in the same block of samples, causing + // the update function to take more than 20ms to complete. + if(locked) phase = 0; syncDetected = false; locked = false; - phase = 0; #ifdef ENABLE_DEMOD_LOG // Pre-arm the log trigger.