From f577c11eb750dec0c52df0c9afddf04832d53dca Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 17 Jan 2022 15:56:16 +0000 Subject: [PATCH] Correct ack diag msgs Bug caused by unsigned ints >32k being displayed as negative int. --- DCCEXParser.cpp | 4 ++-- DCCWaveform.cpp | 4 ++-- StringFormatter.cpp | 1 + version.h | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 7bf7534..a400225 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -741,10 +741,10 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[]) LCD(1, F("Ack Limit=%dmA"), p[2]); // } else if (p[1] == HASH_KEYWORD_MIN) { DCCWaveform::progTrack.setMinAckPulseDuration(p[2]); - LCD(0, F("Ack Min=%dus"), p[2]); // + LCD(0, F("Ack Min=%uus"), p[2]); // } else if (p[1] == HASH_KEYWORD_MAX) { DCCWaveform::progTrack.setMaxAckPulseDuration(p[2]); - LCD(0, F("Ack Max=%dus"), p[2]); // + LCD(0, F("Ack Max=%uus"), p[2]); // } else if (p[1] == HASH_KEYWORD_RETRY) { if (p[2] >255) p[2]=3; LCD(0, F("Ack Retry=%d Sum=%d"), p[2], DCC::setAckRetry(p[2])); // diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 511e7db..2c5ab9a 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -289,7 +289,7 @@ void DCCWaveform::setAckBaseline() { if (isMainTrack) return; int baseline=motorDriver->getCurrentRaw(); ackThreshold= baseline + motorDriver->mA2raw(ackLimitmA); - if (Diag::ACK) DIAG(F("ACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %dus and %dus"), + if (Diag::ACK) DIAG(F("ACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %uus and %uus"), baseline,motorDriver->raw2mA(baseline), ackThreshold,motorDriver->raw2mA(ackThreshold), minAckPulseDuration, maxAckPulseDuration); @@ -309,7 +309,7 @@ void DCCWaveform::setAckPending() { byte DCCWaveform::getAck() { if (ackPending) return (2); // still waiting - if (Diag::ACK) DIAG(F("%S after %dmS max=%d/%dmA pulse=%duS samples=%d gaps=%d"),ackDetected?F("ACK"):F("NO-ACK"), ackCheckDuration, + if (Diag::ACK) DIAG(F("%S after %dmS max=%d/%dmA pulse=%uuS samples=%d gaps=%d"),ackDetected?F("ACK"):F("NO-ACK"), ackCheckDuration, ackMaxCurrent,motorDriver->raw2mA(ackMaxCurrent), ackPulseDuration, numAckSamples, numAckGaps); if (ackDetected) return (1); // Yes we had an ack return(0); // pending set off but not detected means no ACK. diff --git a/StringFormatter.cpp b/StringFormatter.cpp index a5c33cf..73a910f 100644 --- a/StringFormatter.cpp +++ b/StringFormatter.cpp @@ -99,6 +99,7 @@ void StringFormatter::send2(Print * stream,const FSH* format, va_list args) { case 'E': printEscapes(stream,(const FSH*)va_arg(args, char*)); break; case 'S': stream->print((const FSH*)va_arg(args, char*)); break; case 'd': printPadded(stream,va_arg(args, int), formatWidth, formatLeft); break; + case 'u': printPadded(stream,va_arg(args, unsigned int), formatWidth, formatLeft); break; case 'l': printPadded(stream,va_arg(args, long), formatWidth, formatLeft); break; case 'b': stream->print(va_arg(args, int), BIN); break; case 'o': stream->print(va_arg(args, int), OCT); break; diff --git a/version.h b/version.h index 01326c6..277f93b 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,7 @@ #include "StringFormatter.h" -#define VERSION "3.2.0 rc11" +#define VERSION "3.2.0 rc12" // 3.2.0 Major functional and non-functional changes. // New HAL added for I/O (digital and analogue inputs and outputs, servos etc). // Support for MCP23008, MCP23017 and PCF9584 I2C GPIO Extender modules. @@ -25,6 +25,7 @@ // Can define border between long and short addresses // Turnout and accessory states (thrown/closed = 0/1 or 1/0) can be set to match RCN-213 // Bugfix: one-off error in CIPSEND drop +// Bugfix: disgnostic display of ack pulses >32kus // ... // 3.1.7 Bugfix: Unknown locos should have speed forward // 3.1.6 Make output ID two bytes and guess format/size of registered outputs found in EEPROM