From 3dede9eabec96d00e48418b580f193ef245740d1 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 21 Jan 2021 23:06:47 +0000 Subject: [PATCH 1/2] Linear address cmd --- DCCEXParser.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 3ecdb61..d7f45e9 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -306,12 +306,33 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking) return; break; - case 'a': // ACCESSORY - if (p[2] != (p[2] & 1)) - return; - DCC::setAccessory(p[0], p[1], p[2] == 1); + case 'a': // ACCESSORY or + { + int address; + byte subaddress; + byte activep; + if (params==2) { // + address=(p[0] - 1) / 4 + 1; + subaddress=(p[0] - 1) % 4; + activep=1; + } + else if (params==3) { // + address=p[0]; + subaddress=p[1]; + activep=2; + } + else break; // invalid no of parameters + + if ( + ((address & 0x01FF) != address) // invalid address (limit 9 bits ) + || ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits ) + || ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1 + ) break; + + DCC::setAccessory(address, subaddress,p[activep]==1); + } return; - + case 'T': // TURNOUT if (parseT(stream, params, p)) return; From 9399aca63dde1ee7337b8f706f96ae263a084fad Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 21 Jan 2021 23:13:08 +0000 Subject: [PATCH 2/2] Allow lower case keywords --- DCCEXParser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index d7f45e9..8fd0561 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -143,6 +143,7 @@ int DCCEXParser::splitValues(int result[MAX_PARAMS], const byte *cmd) runningValue = 10 * runningValue + (hot - '0'); break; } + if (hot >= 'a' && hot <= 'z') hot=hot-'a'+'A'; // uppercase a..z if (hot >= 'A' && hot <= 'Z') { // Since JMRI got modified to send keywords in some rare cases, we need this