From aeec5447edb5dd7d42a0f3ac75f3400fbb0361c4 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Thu, 13 Nov 2025 12:08:42 -0700 Subject: [PATCH] Revert "Merge pull request #841 from SpudGunMan/master" This reverts commit b4662251ed9f3383d8ad964b42cce395af17dfc2, reversing changes made to 2065598754f382c3f5535314460528fbcd346240. --- meshtastic/serial_interface.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/meshtastic/serial_interface.py b/meshtastic/serial_interface.py index 8d1397c..88f17de 100644 --- a/meshtastic/serial_interface.py +++ b/meshtastic/serial_interface.py @@ -94,16 +94,10 @@ class SerialInterface(StreamInterface): def close(self) -> None: """Close a connection to the device""" - if hasattr(self, "stream") and self.stream and getattr(self.stream, "is_open", False): - try: - self.stream.flush() - time.sleep(0.1) - except Exception as e: - logger.debug(f"Exception during flush: {e}") - try: - self.stream.close() - except Exception as e: - logger.debug(f"Exception during close: {e}") - self.stream = None + if self.stream: # Stream can be null if we were already closed + self.stream.flush() # FIXME: why are there these two flushes with 100ms sleeps? This shouldn't be necessary + time.sleep(0.1) + self.stream.flush() + time.sleep(0.1) logger.debug("Closing Serial stream") StreamInterface.close(self)