From 0dc91451d92e41a1b0d43a282a729aee1b56988c Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Fri, 29 Apr 2022 23:14:27 -0500 Subject: [PATCH 1/2] CALLBACK parameter optional for Write --- DCCEXParser.h | 1 + 1 file changed, 1 insertion(+) diff --git a/DCCEXParser.h b/DCCEXParser.h index 227e3f0..d9fe0e1 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -60,6 +60,7 @@ struct DCCEXParser static int16_t stashP[MAX_COMMAND_PARAMS]; static bool stashCallback(Print * stream, int16_t p[MAX_COMMAND_PARAMS], RingStream * ringStream); static void callback_W(int16_t result); + static void callback_W4(int16_t result); static void callback_B(int16_t result); static void callback_R(int16_t result); static void callback_Rloco(int16_t result); From b2df10a99a506487002c155e8eed1d710c1bed4a Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Fri, 29 Apr 2022 23:23:15 -0500 Subject: [PATCH 2/2] WRITE CV ON PROG Callback parameters are now optional on PROG --- DCCEXParser.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 0d8b537..185c87d 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -352,7 +352,9 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream) break; if (params == 1) // Write new loco id (clearing consist and managing short/long) DCC::setLocoId(p[0],callback_Wloco); - else // WRITE CV ON PROG + else if (params == 4) // WRITE CV ON PROG + DCC::writeCVByte(p[0], p[1], callback_W4); + else // WRITE CV ON PROG DCC::writeCVByte(p[0], p[1], callback_W); return; @@ -947,7 +949,14 @@ void DCCEXParser::commitAsyncReplyStream() { void DCCEXParser::callback_W(int16_t result) { StringFormatter::send(getAsyncReplyStream(), - F("\n"), stashP[2], stashP[3], stashP[0], result == 1 ? stashP[1] : -1); + F("\n"), stashP[0], result == 1 ? stashP[1] : -1); + commitAsyncReplyStream(); +} + +void DCCEXParser::callback_W4(int16_t result) +{ + StringFormatter::send(getAsyncReplyStream(), + F("\n"), stashP[2], stashP[3], stashP[0], result == 1 ? stashP[1] : -1); commitAsyncReplyStream(); }