From 746ccea57d2804e658d469453b30651e84b58dd6 Mon Sep 17 00:00:00 2001 From: Ralf9 Date: Sun, 16 Jun 2019 19:44:55 +0200 Subject: [PATCH] =?UTF-8?q?signalDecoder.cpp=20-=20fix=20MS=20detection=20?= =?UTF-8?q?Es=20werden=20nun=20am=20Anfang=20von=20MS-Nachrichten=20auch?= =?UTF-8?q?=20mehrere=20sync=20in=20Folge=20erkannt=20und=20=C3=BCbersprun?= =?UTF-8?q?gen.=20Bei=20der=20Ausgabe=20werden=20nun=20mit=20"b"=20die?= =?UTF-8?q?=20Position=20des=20ersten=20Sync=20und=20mit=20"s"=20die=20?= =?UTF-8?q?Anzahl=20der=20sync=20ausgegeben.=20Z.B.:=20"...01010;CP=3D1;SP?= =?UTF-8?q?=3D3;R=3D6;O;b63;s4;m0;"=20beim=20GT-WT-02=20Temperatursensor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../signalDecoder/src/signalDecoder.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp b/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp index f90dc62..1f0954c 100644 --- a/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp +++ b/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp @@ -472,18 +472,26 @@ void SignalDetectorClass::processMessage(const uint8_t p_valid) mend = mstart + 12; uint8_t mstartNeu = mstart + 10; + uint8_t mstartAlt = mstart; bool m_endfound = false; while (mstartNeu > mstart) // testen ob innerhalb 10 Zeichen nach dem sync ein weiterer sync folgt, falls ja diesen als neuen mstart verwenden { - //if (message[mend + 1] == sync && message[mend] == clock) { if (message[mstartNeu + 1] == sync) { if (message[mstartNeu] == clock) { + while (mstartNeu < mstartNeu+40 && mstartNeu < (messageLen - minMessageLen)) // alle folgenden sync ueberspringen + { + if (message[mstartNeu + 2] != clock || message[mstartNeu + 3] != sync) { // folgt kein weiterer sync? #ifdef DEBUGDECODE DBG_PRINT(F("MStart:")); DBG_PRINT(mstart); DBG_PRINT(F(" new MStart:")); DBG_PRINTLN(mstartNeu); #endif - mstart = mstartNeu; // weiterer sync -> neuer mstart + mstart = mstartNeu; // weiterer sync -> neuer mstart + mend = mstart + 2; + break; + } + mstartNeu += 2; + } break; } } @@ -616,14 +624,17 @@ void SignalDetectorClass::processMessage(const uint8_t p_valid) MSG_PRINT("O"); MSG_PRINT(SERIAL_DELIMITER); } if (MdebEnabled) { - if (mstart > 1) { - MSG_PRINT("s"); MSG_PRINT(mstart); MSG_PRINT(SERIAL_DELIMITER); - } if (p_valid == 0) { // Nachrichtenende erkannt MSG_PRINT("e"); MSG_PRINT(SERIAL_DELIMITER); } else if (p_valid == 2) { // Patternpuffer overflow MSG_PRINT("p"); MSG_PRINT(SERIAL_DELIMITER); } + if (mstartAlt > 1) { + MSG_PRINT("b"); MSG_PRINT(mstartAlt); MSG_PRINT(SERIAL_DELIMITER); // Position von ersten gefundenen Sync + } + if (mstart > mstartAlt) { + MSG_PRINT(F("s")); MSG_PRINT(mstart - mstartAlt); MSG_PRINT(SERIAL_DELIMITER); // Anzahl der uebersprungenen Sync + } } } m_truncated = false;