From d3dbeaa66613fa260b6751e5bd4cd6a3b62b297a Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 17 Aug 2022 00:28:15 +0200 Subject: [PATCH] bugfix: Wrong condition for ring->commit() --- CommandDistributor.cpp | 4 +++- GITHUB_SHA.h | 2 +- RingStream.cpp | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index c4538cb..9132d8a 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -126,7 +126,9 @@ void CommandDistributor::broadcastToClients(clientType type) { ring->commit(); } } - if (ring->peekTargetMark() == RingStream::NO_CLIENT) { + // at this point ring is committed (NO_CLIENT) either from + // 4 or 13 lines above. + if (rememberClient != RingStream::NO_CLIENT) { //DIAG(F("CD postmark client %d"), rememberClient); ring->mark(rememberClient); } diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 42079cb..17197b8 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "PORTX-HAL-20220816" +#define GITHUB_SHA "PORTX-HAL-20220817" diff --git a/RingStream.cpp b/RingStream.cpp index e639f5d..9db6230 100644 --- a/RingStream.cpp +++ b/RingStream.cpp @@ -107,7 +107,7 @@ int RingStream::read() { if ((_pos_read==_pos_write) && !_overflow) return -1; // empty byte b=readRawByte(); if (b!=FLASH_INSERT_MARKER) return b; - +#ifndef ARDUINO_ARCH_ESP32 // Detected a flash insert // read address bytes LSB first (size depends on CPU) uintptr_t iFlash=0; @@ -119,7 +119,11 @@ int RingStream::read() { } _flashInsert=reinterpret_cast( iFlash); // and try again... so will read the first byte of the insert. - return read(); + return read(); +#else + DIAG(F("Detected flash insert marker at pos %d but there should not be one"),_pos_read); + return '\0'; +#endif } byte RingStream::readRawByte() {