Fix ESP8266 TasmotaSerial flush receive buffer on executing TasmotaSerial.flush();

This commit is contained in:
Theo Arends 2025-12-15 11:26:38 +01:00
parent f36080bf33
commit c35e374739
3 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;
}
}