Skip to content

Commit 73277d3

Browse files
committed
Bugfix: Race condition with RMTChannel::dataRepeat causes packets to be lost #460
1 parent f3dde9c commit 73277d3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

DCCRMT.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ int RMTChannel::RMTfillData(const byte buffer[], byte byteCount, byte repeatCoun
210210
// to the HW. dataRepeat on the other hand signals back to
211211
// the caller of this function if the data has been sent enough
212212
// times (0 to 3 means 1 to 4 times in total).
213-
if (dataRepeat > 0) // we have still old work to do
214-
return dataRepeat;
213+
{
214+
volatile byte dr = dataRepeat; // copy to test variable, not to be optimezed away
215+
if (dr > 0) // we have still old work to do
216+
return dr;
217+
}
215218
if (dataReady == true) // the packet is not copied out yet
216219
return 1000;
217220
if (DATA_LEN(byteCount) > maxDataLen) { // this would overun our allocated memory for data

0 commit comments

Comments
 (0)