From d077be1496a467e4cbc75d0ca10207387569326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 4 Jan 2023 10:37:27 +0100 Subject: [PATCH] add a possibility to flush the serial TX buffer on the console. --- src/SerialConsole.cpp | 6 ++++-- src/SerialConsole.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index 0b6b9ee24..b66eae455 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -20,9 +20,7 @@ void consolePrintf(const char *format, ...) va_start(arg, format); console->vprintf(format, arg); va_end(arg); -#ifdef ARCH_ESP32 console->flush(); -#endif } SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port), concurrency::OSThread("SerialConsole") @@ -51,6 +49,10 @@ int32_t SerialConsole::runOnce() return runOncePart(); } +void SerialConsole::flush() { + Port.flush(); +} + // For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages bool SerialConsole::checkIsConnected() { diff --git a/src/SerialConsole.h b/src/SerialConsole.h index d1f2abac8..f5e2077ba 100644 --- a/src/SerialConsole.h +++ b/src/SerialConsole.h @@ -26,6 +26,8 @@ class SerialConsole : public StreamAPI, public RedirectablePrint, private concur virtual int32_t runOnce() override; + void flush(); + protected: /// Check the current underlying physical link to see if the client is currently connected