1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-04-21 04:21:20 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Harald Barth
830de850a9 version 5.4.1 2025-01-17 19:14:32 +01:00
Harald Barth
c28965c58d ESP32 bugfix packet buffer race 2025-01-17 19:12:11 +01:00
3 changed files with 14 additions and 9 deletions

View File

@ -44,6 +44,12 @@ class RMTChannel {
return true; return true;
return dataReady; 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; }; inline uint32_t packetCount() { return packetCounter; };
private: private:

View File

@ -278,7 +278,11 @@ void DCCWaveform::begin() {
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) { void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
if (byteCount > MAX_PACKET_SIZE) return; // allow for chksum 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; byte checksum = 0;
for (byte b = 0; b < byteCount; b++) { for (byte b = 0; b < byteCount; b++) {
checksum ^= buffer[b]; checksum ^= buffer[b];
@ -296,13 +300,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
{ {
int ret = 0; int ret = 0;
do { do {
if(isMainTrack) { ret = rmtchannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
if (rmtMainChannel != NULL)
ret = rmtMainChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
} else {
if (rmtProgChannel != NULL)
ret = rmtProgChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
}
} while(ret > 0); } while(ret > 0);
} }
} }

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h" #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.4.0 - New version on master
// 5.2.96 - EXRAIL additions XFWD() and XREV() // 5.2.96 - EXRAIL additions XFWD() and XREV()
// 5.2.95 - Release candidate for 5.4 // 5.2.95 - Release candidate for 5.4