diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index b34698d..858f2a5 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -25,6 +25,7 @@ #include "Outputs.h" #include "Sensors.h" #include "freeMemory.h" +#include "GITHUB_SHA.h" #include "EEStore.h" #include "DIAG.h" @@ -222,23 +223,37 @@ void DCCEXParser::parse(Print * stream, byte *com, bool blocking) { return; case 'V': // VERIFY CV ON PROG - if (!stashCallback(stream,p)) break; - if (params==2) DCC::verifyCVByte(p[0],p[1],callback_Vbyte,blocking); - else if (params==3) DCC::verifyCVBit(p[0],p[1],p[2],callback_Vbit,blocking); - else break; - return; - + if (params==2) { // + if (!stashCallback(stream,p)) break; + DCC::verifyCVByte(p[0],p[1],callback_Vbyte,blocking); + return; + } + if (params==3) { + if (!stashCallback(stream,p)) break; + DCC::verifyCVBit(p[0],p[1],p[2],callback_Vbit,blocking); + return; + } + break; + case 'B': // WRITE CV BIT ON PROG if (!stashCallback(stream,p)) break; DCC::writeCVBit(p[0],p[1],p[2],callback_B,blocking); return; - case 'R': // READ CV ON PROG - if (!stashCallback(stream,p)) break; - DCC::readCV(p[0],callback_R,blocking); - return; - + case 'R': // READ CV ON PROG + if (params==3) { // + if (!stashCallback(stream,p)) break; + DCC::readCV(p[0],callback_R,blocking); + return; + } + if (params==0) { // New read loco id + if (!stashCallback(stream,p)) break; + DCC::getLocoId(callback_Rloco,blocking); + return; + } + break; + case '1': // POWERON <1 [MAIN|PROG]> case '0': // POWEROFF <0 [MAIN | PROG] > if (params>1) break; @@ -289,7 +304,7 @@ void DCCEXParser::parse(Print * stream, byte *com, bool blocking) { case 's': // StringFormatter::send(stream,F(""),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON ); - StringFormatter::send(stream,F(""), VERSION, __DATE__, __TIME__ ); + StringFormatter::send(stream,F(""), VERSION, F(GITHUB_SHA)); // TODO Send stats of speed reminders table // TODO send status of turnouts etc etc return; @@ -531,4 +546,9 @@ void DCCEXParser::callback_R(int result) { StringFormatter::send(stashStream,F(""),stashP[1],stashP[2],stashP[0],result); stashBusy=false; } + +void DCCEXParser::callback_Rloco(int result) { + StringFormatter::send(stashStream,F(""),result); + stashBusy=false; +} diff --git a/DCCEXParser.h b/DCCEXParser.h index a90e1b4..e154ff9 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -55,6 +55,7 @@ struct DCCEXParser static void callback_W(int result); static void callback_B(int result); static void callback_R(int result); + static void callback_Rloco(int result); static void callback_Vbit(int result); static void callback_Vbyte(int result); static FILTER_CALLBACK filterCallback; diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h new file mode 100644 index 0000000..cca6c46 --- /dev/null +++ b/GITHUB_SHA.h @@ -0,0 +1 @@ +#define GITHUB_SHA "9db6d36"