mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
Accessory command validations
This commit is contained in:
parent
e7e4d4fbd9
commit
030cb654b4
5
DCC.cpp
5
DCC.cpp
|
@ -81,6 +81,11 @@ static void DCC::setFn( int cab, byte functionNumber, bool on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCC::setAccessory(int address, byte number, bool activate) {
|
void DCC::setAccessory(int address, byte number, bool activate) {
|
||||||
|
// use masks to detect wrong values and do nothing
|
||||||
|
if(address != address & 511)
|
||||||
|
return;
|
||||||
|
if(number != number & 3)
|
||||||
|
return;
|
||||||
byte b[2];
|
byte b[2];
|
||||||
|
|
||||||
b[0] = address % 64 + 128; // first byte is of the form 10AAAAAA, where AAAAAA represent 6 least signifcant bits of accessory address
|
b[0] = address % 64 + 128; // first byte is of the form 10AAAAAA, where AAAAAA represent 6 least signifcant bits of accessory address
|
||||||
|
|
|
@ -133,7 +133,8 @@ void DCCEXParser::parse(Print & stream, const char *com) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE>
|
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE>
|
||||||
DCC::setAccessory(p[0],p[1],p[2]);
|
if(p[2] != p[2] & 1) return;
|
||||||
|
DCC::setAccessory(p[0],p[1],p[2]==1);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'T': // TURNOUT <T ...>
|
case 'T': // TURNOUT <T ...>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user