From 02ed7828c14106a47b9e6d6765b08984cc3ccb6d Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 13 Sep 2022 22:42:38 +0200 Subject: [PATCH] EX-RAIL bugfix: Could not read long loco addrs --- EXRAIL2.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index fb6c9ac..75336fd 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -518,7 +518,15 @@ bool RMFT2::skipIfBlock() { /* static */ void RMFT2::readLocoCallback(int16_t cv) { - progtrackLocoId=cv; + 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); + progtrackLocoId = -1; + } + } else { + progtrackLocoId=cv; + } } void RMFT2::loop() {