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.

This commit is contained in:
Alex Shepherd
2024-08-24 12:39:03 +12:00
parent ee89abe4d7
commit f994cab0c5

View File

@@ -683,7 +683,7 @@ DCC_PROCESSOR_STATE DccProcState ;
portENTER_CRITICAL_ISR (&mux); portENTER_CRITICAL_ISR (&mux);
#endif #endif
DccRx.PacketCopy = DccRx.PacketBuf ; DccRx.PacketCopy = DccRx.PacketBuf ;
DccRx.DataReady = 1 ; DccRx.DataReady += 1 ;
#ifdef ESP32 #ifdef ESP32
portEXIT_CRITICAL_ISR (&mux); portEXIT_CRITICAL_ISR (&mux);
#endif #endif
@@ -1731,6 +1731,8 @@ void NmraDcc::setAccDecDCCAddrNextReceived (uint8_t enable)
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
uint8_t NmraDcc::process() uint8_t NmraDcc::process()
{ {
uint8_t copyDataReady ;
if (DccProcState.inServiceMode) if (DccProcState.inServiceMode)
{ {
if ( (millis() - DccProcState.LastServiceModeMillis) > 20L) if ( (millis() - DccProcState.LastServiceModeMillis) > 20L)
@@ -1748,6 +1750,7 @@ uint8_t NmraDcc::process()
noInterrupts(); noInterrupts();
#endif #endif
Msg = DccRx.PacketCopy ; Msg = DccRx.PacketCopy ;
copyDataReady = DccRx.DataReady;
DccRx.DataReady = 0 ; DccRx.DataReady = 0 ;
#ifdef ESP32 #ifdef ESP32
@@ -1765,7 +1768,7 @@ uint8_t NmraDcc::process()
if (notifyDccMsg) notifyDccMsg (&Msg); if (notifyDccMsg) notifyDccMsg (&Msg);
execDccProcessor (&Msg); execDccProcessor (&Msg);
return 1 ; return copyDataReady ;
} }
return 0 ; return 0 ;