From c35e3747399ef9688f6bb258a127c5a3b5ed678e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:26:38 +0100 Subject: [PATCH] Fix ESP8266 TasmotaSerial flush receive buffer on executing `TasmotaSerial.flush();` --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 238789610..12c820c43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. ### Fixed - DALI watchdog exception - TuyaMCU v1 exception 28 regression from v15.1.0.1 reverted PR24063 (#24220) +- ESP8266 TasmotaSerial flush receive buffer on executing `TasmotaSerial.flush();` ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6932798b3..5371121d7 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -119,5 +119,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Vid6608 library from v1.0.2 to v1.0.3 [#24218](https://github.com/arendst/Tasmota/issues/24218) ### Fixed +- ESP8266 TasmotaSerial flush receive buffer on executing `TasmotaSerial.flush();` - DALI watchdog exception - TuyaMCU v1 exception 28 regression from v15.1.0.1 reverted PR24063 [#24220](https://github.com/arendst/Tasmota/issues/24220) diff --git a/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp index 3b0441e1c..7d67faa10 100644 --- a/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp @@ -353,14 +353,15 @@ bool TasmotaSerial::overflow(void) { void TasmotaSerial::flush(void) { if (m_hardserial) { #ifdef ESP8266 - Serial.flush(); + Serial.flush(); // Flushes Tx only + while (Serial.available()) { Serial.read(); } // Flushes Rx #endif // ESP8266 #ifdef ESP32 TSerial->flush(); // Flushes Tx only https://github.com/espressif/arduino-esp32/pull/4263 - while (TSerial->available()) { TSerial->read(); } + while (TSerial->available()) { TSerial->read(); } // Flushes Rx #endif // ESP32 } else { - m_in_pos = 0; + m_in_pos = 0; // Flushes Rx, Tx is always flushed m_out_pos = 0; } }