From 28be07610ab353551b9937249450503448af6e0a Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 26 May 2020 09:44:20 +0100 Subject: [PATCH] Better diagnostics --- CVReader.ino | 2 +- DCC.cpp | 1 + DCCWaveform.cpp | 8 ++++---- DCCWaveform.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CVReader.ino b/CVReader.ino index 9e06dc6..a95c2ca 100644 --- a/CVReader.ino +++ b/CVReader.ino @@ -28,7 +28,7 @@ void setup() { for (byte x=0;x=0?" VERIFIED OK":"FAILED VERIFICATION"); + DIAG(F("\nCV %d = %d 0x%x %s\n"),cvnums[x],value,value, value>=0?" VERIFIED OK":"FAILED VERIFICATION"); } DIAG(F("\n===== CVReader done ==============================\n")); DIAG(F("\nReady for JMRI commands\n")); diff --git a/DCC.cpp b/DCC.cpp index 091f686..c7ec423 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -182,6 +182,7 @@ byte DCC::cv2(int cv) { bool DCC::verifyCV(int cv, byte value) { byte message[] = { cv1(0x74, cv), cv2(cv), value}; + DIAG(F("\n\nVerifying cv %d = %d"),cv, value); DCCWaveform::progTrack.schedulePacket(message, sizeof(message), 5); return DCCWaveform::progTrack.getAck(); } diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 41a58b3..687ecb7 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -83,7 +83,7 @@ DCCWaveform::DCCWaveform(byte powerPinNo, byte directionPinNo, byte sensePinNo, void DCCWaveform::setPowerMode(POWERMODE mode) { powerMode=mode; digitalWrite2f(powerPin, mode==POWERMODE::ON ? HIGH:LOW); - if (mode==POWERMODE::ON) schedulePacket(resetMessage,2,20); + if (mode==POWERMODE::ON) delay(200); } @@ -213,7 +213,7 @@ void DCCWaveform::checkRailcom() { // Wait until there is no packet pending, then make this pending void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) { if (byteCount>=MAX_PACKET_SIZE) return; // allow for chksum - while(packetPending) delay(1); + while(packetPending); byte checksum=0; for (int b=0;b