From ba9ca1ccadade033531e011d0fbf44c0d35d121f Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 9 Jan 2025 21:42:01 +0100 Subject: [PATCH 1/6] sha --- GITHUB_SHA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index e9bdd6e..f47fd82 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202501091941Z" +#define GITHUB_SHA "c389fe9" From c28965c58d5a14424b9efdd46da6fe0ffaba0273 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 17 Jan 2025 19:12:11 +0100 Subject: [PATCH 2/6] ESP32 bugfix packet buffer race --- DCCRMT.h | 6 ++++++ DCCWaveform.cpp | 14 ++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/DCCRMT.h b/DCCRMT.h index 33257a0..3a20027 100644 --- a/DCCRMT.h +++ b/DCCRMT.h @@ -44,6 +44,12 @@ class RMTChannel { return true; return dataReady; }; + inline void waitForDataCopy() { + while(1) { // do nothing and wait for interrupt clearing dataReady to happen + if (dataReady == false) + break; + } + }; inline uint32_t packetCount() { return packetCounter; }; private: diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 3d77e9e..eb25144 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -278,7 +278,11 @@ void DCCWaveform::begin() { void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) { if (byteCount > MAX_PACKET_SIZE) return; // allow for chksum - + RMTChannel *rmtchannel = (isMainTrack ? rmtMainChannel : rmtProgChannel); + if (rmtchannel == NULL) + return; // no idea to prepare packet if we can not send it anyway + + rmtchannel->waitForDataCopy(); // blocking wait so we can write into buffer byte checksum = 0; for (byte b = 0; b < byteCount; b++) { checksum ^= buffer[b]; @@ -296,13 +300,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea { int ret = 0; do { - if(isMainTrack) { - if (rmtMainChannel != NULL) - ret = rmtMainChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats); - } else { - if (rmtProgChannel != NULL) - ret = rmtProgChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats); - } + ret = rmtchannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats); } while(ret > 0); } } From 830de850a97745c3f493865ca15b5e14bb25615e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 17 Jan 2025 19:14:32 +0100 Subject: [PATCH 3/6] version 5.4.1 --- version.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.h b/version.h index c4c7ba4..a279772 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.4.0" +#define VERSION "5.4.1" +// 5.4.1 - ESP32 bugfix packet buffer race // 5.4.0 - New version on master // 5.2.96 - EXRAIL additions XFWD() and XREV() // 5.2.95 - Release candidate for 5.4 From 2115ada2a1f9a98f2a26eccccfbd2968b9669e71 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 20 Jan 2025 20:03:21 +0000 Subject: [PATCH 4/6] 5.4.2 bugfix fn31 flip --- DCC.cpp | 12 +++--------- version.h | 3 ++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index e60cf25..a5eafec 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -229,15 +229,9 @@ bool DCC::setFn( int cab, int16_t functionNumber, bool on) { // Flip function state (used from withrottle protocol) void DCC::changeFn( int cab, int16_t functionNumber) { - if (cab<=0 || functionNumber>31) return; - int reg = lookupSpeedTable(cab); - if (reg<0) return; - unsigned long funcmask = (1UL<28 // 5.4.1 - ESP32 bugfix packet buffer race // 5.4.0 - New version on master // 5.2.96 - EXRAIL additions XFWD() and XREV() From b40fa779a64ff17997185e66e40d37e0ba62b13c Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 20 Jan 2025 22:40:43 +0100 Subject: [PATCH 5/6] revert part of commit 3c725a which did fix bug but reverse direction --- DCCEXParser.cpp | 2 +- Turnouts.cpp | 2 +- config.example.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index ad577ff..ff73375 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -403,7 +403,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) ) break; // Honour the configuration option (config.h) which allows the command to be reversed // Because of earlier confusion we need to do the same thing under both defines -#if defined(DCC_ACCESSORY_COMMAND_REVERSE) || defined(DCC_ACCESSORY_RCN_213) +#if defined(DCC_ACCESSORY_COMMAND_REVERSE) DCC::setAccessory(address, subaddress,p[activep]==0,onoff); #else DCC::setAccessory(address, subaddress,p[activep]==1,onoff); diff --git a/Turnouts.cpp b/Turnouts.cpp index 8e212ed..dfe9615 100644 --- a/Turnouts.cpp +++ b/Turnouts.cpp @@ -379,7 +379,7 @@ // DCC++ Classic behaviour is that Throw writes a 1 in the packet, // and Close writes a 0. // RCN-213 specifies that Throw is 0 and Close is 1. -#if defined(DCC_TURNOUTS_RCN_213) +#ifndef DCC_TURNOUTS_RCN_213 close = !close; #endif DCC::setAccessory(_dccTurnoutData.address, _dccTurnoutData.subAddress, close); diff --git a/config.example.h b/config.example.h index 4d107aa..6aba226 100644 --- a/config.example.h +++ b/config.example.h @@ -269,8 +269,8 @@ The configuration file for DCC-EX Command Station // over DCC++. This #define likewise inverts the behaviour of the command // for triggering DCC Accessory Decoders, so that generates a // DCC packet with D=1 (close turnout) and generates D=0 -// (throw turnout). This is the same as DCC_ACCESSORY_COMMAND_REVERSE -//#define DCC_ACCESSORY_RCN_213 +// (throw turnout). +//#define DCC_ACCESSORY_COMMAND_REVERSE // HANDLING MULTIPLE SERIAL THROTTLES From 865f75dda4edf819662888b919aa65ec05945c9f Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 20 Jan 2025 22:41:47 +0100 Subject: [PATCH 6/6] version 5.4.2 --- version.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.h b/version.h index a279772..b34b350 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.4.1" +#define VERSION "5.4.2" +// 5.4.2 - Reversed turnout bugfix // 5.4.1 - ESP32 bugfix packet buffer race // 5.4.0 - New version on master // 5.2.96 - EXRAIL additions XFWD() and XREV()