Skip to content

Commit

Permalink
Restore ackManagerByte before retry Verify
Browse files Browse the repository at this point in the history
Identify where initial value was not verified, but initial value returned with subsequent Read.
RCOUNT removed.  BIV and ITCBV added.
  • Loading branch information
Ash-4 authored Sep 5, 2021
1 parent 8d471d9 commit 4dff8a2
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions DCC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 };


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4dff8a2

Please sign in to comment.