From 140c9fc6d59b013bf7857b124db7e3021a53886f Mon Sep 17 00:00:00 2001 From: Antonio Paolillo Date: Thu, 12 Mar 2026 18:47:52 +0100 Subject: [PATCH] comm/uart: Add flush method Signed-off-by: Antonio Paolillo --- benchkit/communication/uart.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/benchkit/communication/uart.py b/benchkit/communication/uart.py index 2169d2ff..ab5a07b0 100644 --- a/benchkit/communication/uart.py +++ b/benchkit/communication/uart.py @@ -83,6 +83,12 @@ def close_comm(self) -> None: def _unchecked_close_comm(self) -> None: self._con.close() # type: ignore + def flush(self) -> None: + """Drain any pending bytes from the UART receive buffer.""" + if not self.is_open(): + self.start_comm() + self._con.reset_input_buffer() + def listen( self, chunk_size: int = 16,