From a5ccb2e29e297d3743f3b8e8a3edcc17fd807842 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 23 Nov 2023 14:15:58 +0000 Subject: [PATCH] EXRAIL STASH --- DCCEXParser.cpp | 7 +++++++ EXRAIL2.cpp | 2 +- EXRAIL2Parser.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- version.h | 4 +++- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 8a81616..abbf54a 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -160,6 +160,7 @@ const int16_t HASH_KEYWORD_C='C'; const int16_t HASH_KEYWORD_G='G'; const int16_t HASH_KEYWORD_H='H'; const int16_t HASH_KEYWORD_I='I'; +const int16_t HASH_KEYWORD_M='M'; const int16_t HASH_KEYWORD_O='O'; const int16_t HASH_KEYWORD_P='P'; const int16_t HASH_KEYWORD_R='R'; @@ -729,6 +730,12 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) StringFormatter::send(stream, F("\n")); return; + case HASH_KEYWORD_M: // intercepted by EXRAIL + if (params>1) break; // invalid cant do + // requests stash size so say none. + StringFormatter::send(stream,F("\n")); + return; + case HASH_KEYWORD_R: // returns rosters StringFormatter::send(stream, F(" commands to do the following: // - Implement RMFT specific commands/diagnostics @@ -149,7 +151,33 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16 opcode=0; return; } - break; + break; + case HASH_KEYWORD_M: + // NOTE: we only need to handle valid calls here because + // DCCEXParser has to have code to handle the cases where + // exrail isnt involved anyway. + // This entire code block is compiled out if STASH macros not used + if (!(compileFeatures & FEATURE_STASH)) return; + if (paramCount==1) { // + StringFormatter::send(stream,F("\n"),maxStashId); + opcode=0; + break; + } + if (paramCount==2) { // + if (p[1]<=0 || p[1]>maxStashId) break; + StringFormatter::send(stream,F("\n"), + p[1],stashArray[p[1]]); + opcode=0; + break; + } + if (paramCount==3) { // + if (p[1]<=0 || p[1]>maxStashId) break; + stashArray[p[1]]=p[2]; + opcode=0; + break; + } + break; + default: break; } @@ -195,6 +223,15 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) { sigid & SIGNAL_ID_MASK); } } + + if (compileFeatures & FEATURE_STASH) { + for (int i=1;i<=maxStashId;i++) { + if (stashArray[i]) + StringFormatter::send(stream,F("\nSTASH[%d] Loco=%d"), + i, stashArray[i]); + } + } + StringFormatter::send(stream,F(" *>\n")); return true; } diff --git a/version.h b/version.h index a39bdc3..2d89cd0 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,9 @@ #include "StringFormatter.h" -#define VERSION "5.2.8" +#define VERSION "5.2.9" +// 5.2.9 - Bugfix LCD startup with no LCD, uses <@ +// 5.2.9 - EXRAIL STASH feature // 5.2.8 - Bugfix: Do not turn off all tracks on change // give better power messages // 5.2.7 - Bugfix: EXRAIL ling segment