1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00

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.
This commit is contained in:
Ash-4 2021-09-05 16:43:24 -05:00 committed by GitHub
parent 8d471d9f3f
commit 4dff8a2b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

27
DCC.cpp
View File

@ -357,9 +357,9 @@ const ackOp FLASH WRITE_BYTE_PROG[] = {
const ackOp FLASH VERIFY_BYTE_PROG[] = { const ackOp FLASH VERIFY_BYTE_PROG[] = {
BASELINE, BASELINE,
BIV, // ackManagerByte initial value
VB,WACK, // validate byte VB,WACK, // validate byte
ITCB, // if ok callback value ITCB, // if ok callback value
RCOUNT, // increment ackRetry counter
STARTMERGE, //clear bit and byte values ready for merge pass STARTMERGE, //clear bit and byte values ready for merge pass
// each bit is validated against 0 and the result inverted in MERGE // 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. // 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, 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 }; FAIL };
@ -689,6 +689,7 @@ int DCC::nextLoco = 0;
ackOp const * DCC::ackManagerProg; ackOp const * DCC::ackManagerProg;
ackOp const * DCC::ackManagerProgStart; ackOp const * DCC::ackManagerProgStart;
byte DCC::ackManagerByte; byte DCC::ackManagerByte;
byte DCC::ackManagerByteVerify;
byte DCC::ackManagerStash; byte DCC::ackManagerStash;
int DCC::ackManagerWord; int DCC::ackManagerWord;
byte DCC::ackManagerRetry; byte DCC::ackManagerRetry;
@ -730,6 +731,7 @@ void DCC::ackManagerSetup(int cv, byte byteValueOrBitnum, ackOp const program[]
ackManagerProgStart = program; ackManagerProgStart = program;
ackManagerRetry = ackRetry; ackManagerRetry = ackRetry;
ackManagerByte = byteValueOrBitnum; ackManagerByte = byteValueOrBitnum;
ackManagerByteVerify = byteValueOrBitnum;
ackManagerBitNum=byteValueOrBitnum; ackManagerBitNum=byteValueOrBitnum;
ackManagerCallback = callback; ackManagerCallback = callback;
} }
@ -828,7 +830,18 @@ void DCC::ackManagerLoop() {
return; return;
} }
break; 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) case ITCB7: // If True callback(byte & 0x7F)
if (ackReceived) { if (ackReceived) {
callback(ackManagerByte & 0x7F); callback(ackManagerByte & 0x7F);
@ -847,8 +860,8 @@ void DCC::ackManagerLoop() {
callback(-1); callback(-1);
return; return;
case RCOUNT: // ackRetry counter case BIV: // ackManagerByte initial value
ackRetrySum++; ackManagerByte = ackManagerByteVerify;
break; break;
case STARTMERGE: case STARTMERGE:
@ -919,7 +932,7 @@ void DCC::callback(int value) {
// check for automatic retry // check for automatic retry
if (value == -1 && ackManagerRetry > 0) { if (value == -1 && ackManagerRetry > 0) {
ackRetrySum ++; 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 --; ackManagerRetry --;
ackManagerProg = ackManagerProgStart; ackManagerProg = ackManagerProgStart;
return; return;