mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
add checks for broken cab ID
This commit is contained in:
parent
df7b890758
commit
3759fc2a1a
|
@ -286,6 +286,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
|
|
||||||
if (direction < 0 || direction > 1)
|
if (direction < 0 || direction > 1)
|
||||||
break; // invalid direction code
|
break; // invalid direction code
|
||||||
|
if (cab > 10239 || cab < 0)
|
||||||
|
break; // beyond DCC range
|
||||||
|
|
||||||
DCC::setThrottle(cab, tspeed, direction);
|
DCC::setThrottle(cab, tspeed, direction);
|
||||||
if (params == 4) // send obsolete format T response
|
if (params == 4) // send obsolete format T response
|
||||||
|
|
|
@ -235,6 +235,10 @@ int WiThrottle::getLocoId(byte * cmd) {
|
||||||
void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
|
void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
|
||||||
char throttleChar=cmd[1];
|
char throttleChar=cmd[1];
|
||||||
int locoid=getLocoId(cmd+3); // -1 for *
|
int locoid=getLocoId(cmd+3); // -1 for *
|
||||||
|
if (locoid > 10239 || locoid < -1) {
|
||||||
|
StringFormatter::send(stream, F("No valid DCC loco %d\n"), locoid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
byte * aval=cmd;
|
byte * aval=cmd;
|
||||||
while(*aval !=';' && *aval !='\0') aval++;
|
while(*aval !=';' && *aval !='\0') aval++;
|
||||||
if (*aval) aval+=2; // skip ;>
|
if (*aval) aval+=2; // skip ;>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user