1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-25 05:31:24 +01:00

ACK RETRY

ACK retry code added to ackManagerSetup and callback.
The default is <D ACK RETRY 1>.  For ACK tuning, set retry to zero.
Retry count is captured on the LCD display, and lines in the serial monitor.
This commit is contained in:
Ash-4 2021-08-21 00:54:28 -05:00 committed by GitHub
parent b67027a1ed
commit 11cd216017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

15
DCC.cpp
View File

@ -679,9 +679,13 @@ int DCC::nextLoco = 0;
//ACK MANAGER //ACK MANAGER
ackOp const * DCC::ackManagerProg; ackOp const * DCC::ackManagerProg;
ackOp const * DCC::ackManagerProgStart;
byte DCC::ackManagerByte; byte DCC::ackManagerByte;
byte DCC::ackManagerStash; byte DCC::ackManagerStash;
int DCC::ackManagerWord; int DCC::ackManagerWord;
int DCC::ackManagerRetry;
int DCC::ackRetry = 1;
int DCC::ackRetrySum;
int DCC::ackManagerCv; int DCC::ackManagerCv;
byte DCC::ackManagerBitNum; byte DCC::ackManagerBitNum;
bool DCC::ackReceived; bool DCC::ackReceived;
@ -714,6 +718,8 @@ void DCC::ackManagerSetup(int cv, byte byteValueOrBitnum, ackOp const program[]
ackManagerCv = cv; ackManagerCv = cv;
ackManagerProg = program; ackManagerProg = program;
ackManagerProgStart = program;
ackManagerRetry = ackRetry;
ackManagerByte = byteValueOrBitnum; ackManagerByte = byteValueOrBitnum;
ackManagerBitNum=byteValueOrBitnum; ackManagerBitNum=byteValueOrBitnum;
ackManagerCallback = callback; ackManagerCallback = callback;
@ -897,6 +903,15 @@ void DCC::ackManagerLoop() {
} }
void DCC::callback(int value) { void DCC::callback(int value) {
// check for automatic retry
if (value == -1 && ackManagerRetry > 0) {
ackRetrySum ++;
StringFormatter::lcd(0, F("%d %d %d %d %d %d"), ackManagerCv, ackManagerRetry, ackRetry, ackRetrySum, ackManagerProg, ackManagerProgStart);
ackManagerRetry -= 1;
ackManagerProg = ackManagerProgStart;
return;
}
static unsigned long callbackStart; static unsigned long callbackStart;
// We are about to leave programming mode // We are about to leave programming mode
// Rule 1: If we have written to a decoder we must maintain power for 100mS // Rule 1: If we have written to a decoder we must maintain power for 100mS