From 151f7d7f8686ef7718aec10d643418f419b09f21 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 21 Oct 2021 22:44:25 +0100 Subject: [PATCH] Fixup EXRAIL Read Loco issues --- RMFT2.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RMFT2.cpp b/RMFT2.cpp index a117318..a6dd935 100644 --- a/RMFT2.cpp +++ b/RMFT2.cpp @@ -44,6 +44,7 @@ const int16_t HASH_KEYWORD_ROUTES=-3702; // The thrrads exist in a ring, each time through loop() the next thread in the ring is serviced. // Statics +const int16_t LOCO_ID_WAITING=-99; // waiting for loco id from prog track int16_t RMFT2::progtrackLocoId; // used for callback when detecting a loco on prograck bool RMFT2::diag=false; // RMFT2 * RMFT2::loopTask=NULL; // loopTask contains the address of ONE of the tasks in a ring. @@ -595,14 +596,20 @@ void RMFT2::loop2() { break; case OPCODE_READ_LOCO1: // READ_LOCO is implemented as 2 separate opcodes + progtrackLocoId=LOCO_ID_WAITING; // Nothing found yet DCC::getLocoId(readLocoCallback); break; case OPCODE_READ_LOCO2: - if (progtrackLocoId<0) { + if (progtrackLocoId==LOCO_ID_WAITING) { delayMe(100); return; // still waiting for callback } + if (progtrackLocoId<0) { + kill(F("No Loco Found"),progtrackLocoId); + return; // still waiting for callback + } + loco=progtrackLocoId; speedo=0; forward=true;