From 0b3e904ffb01bb8cf03950510682613621935dbf Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 30 Jan 2021 22:53:05 +0100 Subject: [PATCH 1/2] correct logic in setLocoId --- DCC.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index f192ef5..b658fce 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -480,10 +480,14 @@ void DCC::getLocoId(ACK_CALLBACK callback, bool blocking) { } void DCC::setLocoId(int id,ACK_CALLBACK callback, bool blocking) { - if (id<=0 || id>9999) callback(-1); - int wordval; - if (id<=127) ackManagerSetup(id,SHORT_LOCO_ID_PROG, callback, blocking); - else ackManagerSetup(id | 0xc000,LONG_LOCO_ID_PROG, callback, blocking); + if (id<1 || id>10239) { //0x27FF according to standard + callback(-1); + return; + } + if (id<=127) + ackManagerSetup(id, SHORT_LOCO_ID_PROG, callback, blocking); + else + ackManagerSetup(id | 0xc000,LONG_LOCO_ID_PROG, callback, blocking); } void DCC::forgetLoco(int cab) { // removes any speed reminders for this loco From 6cc5550927fa74195cf5cd177c25df9a08c0d75b Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 30 Jan 2021 22:54:38 +0100 Subject: [PATCH 2/2] result should be as is (can be -1 to indicate fail) --- DCCEXParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 04546a3..010cf8b 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -791,7 +791,7 @@ void DCCEXParser::callback_R(int result) void DCCEXParser::callback_Rloco(int result) { - StringFormatter::send(stashStream, F(""), result & 0x3FFF); + StringFormatter::send(stashStream, F(""), result); stashBusy = false; }