1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-25 21:41:23 +01:00

Merge branch 'LinearA' into nanoEvery2

This commit is contained in:
Asbelos 2021-01-26 12:00:22 +00:00
commit b8d61fb839

View File

@ -143,6 +143,7 @@ int DCCEXParser::splitValues(int result[MAX_PARAMS], const byte *cmd)
runningValue = 10 * runningValue + (hot - '0'); runningValue = 10 * runningValue + (hot - '0');
break; break;
} }
if (hot >= 'a' && hot <= 'z') hot=hot-'a'+'A'; // uppercase a..z
if (hot >= 'A' && hot <= 'Z') if (hot >= 'A' && hot <= 'Z')
{ {
// Since JMRI got modified to send keywords in some rare cases, we need this // Since JMRI got modified to send keywords in some rare cases, we need this
@ -314,10 +315,31 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking)
return; return;
break; break;
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE> case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE> or <a LINEARADDRESS ACTIVATE>
if (p[2] != (p[2] & 1)) {
return; int address;
DCC::setAccessory(p[0], p[1], p[2] == 1); byte subaddress;
byte activep;
if (params==2) { // <a LINEARADDRESS ACTIVATE>
address=(p[0] - 1) / 4 + 1;
subaddress=(p[0] - 1) % 4;
activep=1;
}
else if (params==3) { // <a ADDRESS SUBADDRESS ACTIVATE>
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; return;
case 'T': // TURNOUT <T ...> case 'T': // TURNOUT <T ...>