From 08810dafd7eedc7cdb52c10626afb8a4b3ede97d Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Mon, 30 Aug 2021 16:37:06 -0500 Subject: [PATCH 1/7] Update retry counter will also display running total prior to its reset. RCOUNT step included in Verify program will count when Verify fails --- DCC.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DCC.h b/DCC.h index cf1680f..c7dcbe0 100644 --- a/DCC.h +++ b/DCC.h @@ -41,6 +41,7 @@ enum ackOp : byte ITCB7, // If True callback(byte &0x7F) NAKFAIL, // if false callback(-1) FAIL, // callback(-1) + RCOUNT, // increment ackRetry counter STARTMERGE, // Clear bit and byte settings ready for merge pass MERGE, // Merge previous wack response with byte value and decrement bit number (use for readimng CV bytes) SETBIT, // sets bit number to next prog byte @@ -115,9 +116,11 @@ public: static inline void setGlobalSpeedsteps(byte s) { globalSpeedsteps = s; }; - static inline void setAckRetry(byte retry) { + static inline int16_t setAckRetry(byte retry) { ackRetry = retry; + ackRetryPSum = ackRetrySum; ackRetrySum = 0; // reset running total + return ackRetryPSum; }; private: @@ -154,6 +157,7 @@ private: static byte ackManagerRetry; static byte ackRetry; static int16_t ackRetrySum; + static int16_t ackRetryPSum; static int ackManagerWord; static byte ackManagerStash; static bool ackReceived; From 4b87c879a9d5dc32c97d205a08b222a9a692cb4b Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Mon, 30 Aug 2021 16:52:50 -0500 Subject: [PATCH 2/7] RCOUNT step added to Verify byte program --- DCC.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DCC.cpp b/DCC.cpp index 79c5b19..f5470b2 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -359,6 +359,7 @@ const ackOp FLASH VERIFY_BYTE_PROG[] = { BASELINE, VB,WACK, // validate byte ITCB, // if ok callback value + RCOUNT, // increment ackRetry counter STARTMERGE, //clear bit and byte values ready for merge pass // each bit is validated against 0 and the result inverted in MERGE // this is because there tend to be more zeros in cv values than ones. @@ -693,6 +694,7 @@ int DCC::ackManagerWord; byte DCC::ackManagerRetry; byte DCC::ackRetry = 2; int16_t DCC::ackRetrySum; +int16_t DCC::ackRetryPSum; int DCC::ackManagerCv; byte DCC::ackManagerBitNum; bool DCC::ackReceived; @@ -844,7 +846,11 @@ void DCC::ackManagerLoop() { case FAIL: // callback(-1) callback(-1); return; - + + case RCOUNT: // ackRetry counter + ackRetrySum++; + break; + case STARTMERGE: ackManagerBitNum=7; ackManagerByte=0; From b4fb76b6c865461318ca0923818401e383f12d0c Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Mon, 30 Aug 2021 17:02:05 -0500 Subject: [PATCH 3/7] Display running total ackRetrySum RCOUNT added to Verify program to report if Read step occurs. Report ackRetrySum on LCD when is sent --- DCCEXParser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 91039f7..d09aa1b 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -820,8 +820,7 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[]) LCD(0, F("Ack Max=%dus"), p[2]); // } else if (p[1] == HASH_KEYWORD_RETRY) { if (p[2] >255) p[2]=3; - DCC::setAckRetry(p[2]); - LCD(0, F("Ack Retry=%d"), p[2]); // + LCD(0, F("Ack Retry=%d Sum=%d"), p[2], DCC::setAckRetry(p[2])); // } } else { StringFormatter::send(stream, F("Ack diag %S\n"), onOff ? F("on") : F("off")); From 8d471d9f3f1e3e016c5f1909c69e178a1bd53719 Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Sun, 5 Sep 2021 16:19:03 -0500 Subject: [PATCH 4/7] Restore ackManagerByte before retry Verify --- DCC.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DCC.h b/DCC.h index c7dcbe0..8cb5d97 100644 --- a/DCC.h +++ b/DCC.h @@ -38,10 +38,11 @@ enum ackOp : byte ITC1, // If True Callback(1) (if prevous WACK got an ACK) ITC0, // If True callback(0); ITCB, // If True callback(byte) + ITCBV, // If True callback(byte) - end of Verify Byte ITCB7, // If True callback(byte &0x7F) NAKFAIL, // if false callback(-1) FAIL, // callback(-1) - RCOUNT, // increment ackRetry counter + BIV, // Set ackManagerByte to initial value for Verify retry STARTMERGE, // Clear bit and byte settings ready for merge pass MERGE, // Merge previous wack response with byte value and decrement bit number (use for readimng CV bytes) SETBIT, // sets bit number to next prog byte @@ -152,6 +153,7 @@ private: static ackOp const *ackManagerProg; static ackOp const *ackManagerProgStart; static byte ackManagerByte; + static byte ackManagerByteVerify; static byte ackManagerBitNum; static int ackManagerCv; static byte ackManagerRetry; From 4dff8a2b50ac23ce6aaba81fac0b870e9047d1ce Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Sun, 5 Sep 2021 16:43:24 -0500 Subject: [PATCH 5/7] Restore ackManagerByte before retry Verify Identify where initial value was not verified, but initial value returned with subsequent Read. RCOUNT removed. BIV and ITCBV added. --- DCC.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index f5470b2..5165f72 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -357,9 +357,9 @@ const ackOp FLASH WRITE_BYTE_PROG[] = { const ackOp FLASH VERIFY_BYTE_PROG[] = { BASELINE, + BIV, // ackManagerByte initial value VB,WACK, // validate byte - ITCB, // if ok callback value - RCOUNT, // increment ackRetry counter + ITCB, // if ok callback value STARTMERGE, //clear bit and byte values ready for merge pass // each bit is validated against 0 and the result inverted in MERGE // this is because there tend to be more zeros in cv values than ones. @@ -377,7 +377,7 @@ const ackOp FLASH VERIFY_BYTE_PROG[] = { V0, WACK, MERGE, V0, WACK, MERGE, V0, WACK, MERGE, - VB, WACK, ITCB, // verify merged byte and return it if acked ok + VB, WACK, ITCBV, // verify merged byte and return it if acked ok - with retry report FAIL }; @@ -689,6 +689,7 @@ int DCC::nextLoco = 0; ackOp const * DCC::ackManagerProg; ackOp const * DCC::ackManagerProgStart; byte DCC::ackManagerByte; +byte DCC::ackManagerByteVerify; byte DCC::ackManagerStash; int DCC::ackManagerWord; byte DCC::ackManagerRetry; @@ -730,6 +731,7 @@ void DCC::ackManagerSetup(int cv, byte byteValueOrBitnum, ackOp const program[] ackManagerProgStart = program; ackManagerRetry = ackRetry; ackManagerByte = byteValueOrBitnum; + ackManagerByteVerify = byteValueOrBitnum; ackManagerBitNum=byteValueOrBitnum; ackManagerCallback = callback; } @@ -828,7 +830,18 @@ void DCC::ackManagerLoop() { return; } break; - + + case ITCBV: // If True callback(byte) - Verify + if (ackReceived) { + if (ackManagerByte == ackManagerByteVerify) { + ackRetrySum ++; + LCD(1, F("v %d %d Sum=%d"), ackManagerCv, ackManagerByte, ackRetrySum); + } + callback(ackManagerByte); + return; + } + break; + case ITCB7: // If True callback(byte & 0x7F) if (ackReceived) { callback(ackManagerByte & 0x7F); @@ -847,8 +860,8 @@ void DCC::ackManagerLoop() { callback(-1); return; - case RCOUNT: // ackRetry counter - ackRetrySum++; + case BIV: // ackManagerByte initial value + ackManagerByte = ackManagerByteVerify; break; case STARTMERGE: @@ -919,7 +932,7 @@ void DCC::callback(int value) { // check for automatic retry if (value == -1 && ackManagerRetry > 0) { ackRetrySum ++; - LCD(0, F("RETRY %d %d %d %d"), ackManagerCv, ackManagerRetry, ackRetry, ackRetrySum); + LCD(0, F("Retry %d %d Sum=%d"), ackManagerCv, ackManagerRetry, ackRetrySum); ackManagerRetry --; ackManagerProg = ackManagerProgStart; return; From f8311b8c56a7793db210884cde7c385c475b2cbb Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Wed, 8 Sep 2021 14:00:42 -0500 Subject: [PATCH 6/7] line added sentResetsSincePacket in DCCWaveform::setPowerMode(POWERMODE mode) -- to pause while power is off due to PROG TRACK POWER OVERLOAD and line added after case BASELINE in DCC.cpp --- DCCWaveform.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 0d23897..a82d36c 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -114,6 +114,7 @@ void DCCWaveform::setPowerMode(POWERMODE mode) { powerMode = mode; bool ison = (mode == POWERMODE::ON); motorDriver->setPower( ison); + sentResetsSincePacket=0; } From ebabbbe59e07685fad80941b34440cd23ce68f78 Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Wed, 8 Sep 2021 14:06:39 -0500 Subject: [PATCH 7/7] pause program steps if OVERLOAD line added to pause program steps during OVERLOAD. case BASELINE if (DCCWaveform::progTrack.getPowerMode()==POWERMODE::OVERLOAD) return; -- also added a line in DCCWaveform.cpp --- DCC.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DCC.cpp b/DCC.cpp index 5165f72..f747362 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -757,6 +757,7 @@ void DCC::ackManagerLoop() { // (typically waiting for a reset counter or ACK waiting, or when all finished.) switch (opcode) { case BASELINE: + if (DCCWaveform::progTrack.getPowerMode()==POWERMODE::OVERLOAD) return; if (checkResets(DCCWaveform::progTrack.autoPowerOff || ackManagerRejoin ? 20 : 3)) return; DCCWaveform::progTrack.setAckBaseline(); callbackState=READY;