diff --git a/DCC.cpp b/DCC.cpp index 433911d..f776b04 100644 --- a/DCC.cpp +++ b/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) { + // use masks to detect wrong values and do nothing + if(address != address & 511) + return; + if(number != number & 3) + return; 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 diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 77faf0a..4bfed24 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -133,7 +133,8 @@ void DCCEXParser::parse(Print & stream, const char *com) { break; case 'a': // ACCESSORY - 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; case 'T': // TURNOUT