From c07ac38ab11240fe7d0d8d894d568008599e3b1e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 4 Sep 2024 09:11:51 +0200 Subject: [PATCH] EXRAIL: Catch CV read errors in the callback --- EXRAIL2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 1a7f888..bfa011d 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -478,10 +478,15 @@ bool RMFT2::skipIfBlock() { /* static */ void RMFT2::readLocoCallback(int16_t cv) { + if (cv <= 0) { + DIAG(F("CV read error")); + progtrackLocoId = -1; + return; + } if (cv & LONG_ADDR_MARKER) { // maker bit indicates long addr progtrackLocoId = cv ^ LONG_ADDR_MARKER; // remove marker bit to get real long addr if (progtrackLocoId <= HIGHEST_SHORT_ADDR ) { // out of range for long addr - DIAG(F("Long addr %d <= %d unsupported\n"), progtrackLocoId, HIGHEST_SHORT_ADDR); + DIAG(F("Long addr %d <= %d unsupported"), progtrackLocoId, HIGHEST_SHORT_ADDR); progtrackLocoId = -1; } } else {