From f994cab0c52e7805781f457a78aeabf568fe093a Mon Sep 17 00:00:00 2001 From: Alex Shepherd Date: Sat, 24 Aug 2024 12:39:03 +1200 Subject: [PATCH] Changes the return from NmraDcc::process() to be the number of times a DCC Packet is ready to be able to detect DCC packet buffer overflow. --- NmraDcc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NmraDcc.cpp b/NmraDcc.cpp index 1742e84..cf55056 100644 --- a/NmraDcc.cpp +++ b/NmraDcc.cpp @@ -683,7 +683,7 @@ DCC_PROCESSOR_STATE DccProcState ; portENTER_CRITICAL_ISR (&mux); #endif DccRx.PacketCopy = DccRx.PacketBuf ; - DccRx.DataReady = 1 ; + DccRx.DataReady += 1 ; #ifdef ESP32 portEXIT_CRITICAL_ISR (&mux); #endif @@ -1731,6 +1731,8 @@ void NmraDcc::setAccDecDCCAddrNextReceived (uint8_t enable) //////////////////////////////////////////////////////////////////////// uint8_t NmraDcc::process() { + uint8_t copyDataReady ; + if (DccProcState.inServiceMode) { if ( (millis() - DccProcState.LastServiceModeMillis) > 20L) @@ -1748,6 +1750,7 @@ uint8_t NmraDcc::process() noInterrupts(); #endif Msg = DccRx.PacketCopy ; + copyDataReady = DccRx.DataReady; DccRx.DataReady = 0 ; #ifdef ESP32 @@ -1765,7 +1768,7 @@ uint8_t NmraDcc::process() if (notifyDccMsg) notifyDccMsg (&Msg); execDccProcessor (&Msg); - return 1 ; + return copyDataReady ; } return 0 ;