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,