From 794128fe4b6cae966e3889748cbf134bb072cbb8 Mon Sep 17 00:00:00 2001 From: Roeland Date: Mon, 19 Aug 2019 08:59:29 +0200 Subject: [PATCH 1/2] Update NmraDcc.cpp (#28) Changed the Service Mode duplicate packet comparison to only compare the packet Size and Data fields and ignore the number of Preamble bits as some command stations appear to send different numbers of preamble bits for otherwise duplicated packets, so we detecting the required two identical packets in sequence and performing the ServiceMode Operation --- NmraDcc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NmraDcc.cpp b/NmraDcc.cpp index 9e0295c..66470fe 100644 --- a/NmraDcc.cpp +++ b/NmraDcc.cpp @@ -1096,7 +1096,8 @@ void execDccProcessor( DCC_MSG * pDccMsg ) { resetServiceModeTimer( 1 ) ; - if( memcmp( pDccMsg, &DccProcState.LastMsg, sizeof( DCC_MSG ) ) ) + //Check if size and data content of the DCC match with previous packed + if(pDccMsg->Size != DccProcState.LastMsg.Size || memcmp( pDccMsg->Data, &DccProcState.LastMsg.Data, pDccMsg->Size ) != 0 ) { DccProcState.DuplicateCount = 0 ; memcpy( &DccProcState.LastMsg, pDccMsg, sizeof( DCC_MSG ) ) ; From d8fb99ed919790838efbca3aee294b28ce7e2f66 Mon Sep 17 00:00:00 2001 From: Alex Shepherd Date: Mon, 19 Aug 2019 19:04:51 +1200 Subject: [PATCH 2/2] Update NmraDcc.cpp Added some more comments to the ServiceMode programming DCC Packet comparison logic --- NmraDcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NmraDcc.cpp b/NmraDcc.cpp index 66470fe..978da60 100644 --- a/NmraDcc.cpp +++ b/NmraDcc.cpp @@ -1096,7 +1096,7 @@ void execDccProcessor( DCC_MSG * pDccMsg ) { resetServiceModeTimer( 1 ) ; - //Check if size and data content of the DCC match with previous packed + //Only check the DCC Packet "Size" and "Data" fields and ignore the "PreambleBits" as they can be different to the previous packet if(pDccMsg->Size != DccProcState.LastMsg.Size || memcmp( pDccMsg->Data, &DccProcState.LastMsg.Data, pDccMsg->Size ) != 0 ) { DccProcState.DuplicateCount = 0 ;