From f15a0bdc0bd3d847b24f852f35efc6541f4a5d42 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Thu, 13 Nov 2025 11:38:00 -0700 Subject: [PATCH] Add more exception logging, fix some additional stream read/write issues --- meshtastic/stream_interface.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/meshtastic/stream_interface.py b/meshtastic/stream_interface.py index 82b6ab5..dc4109e 100644 --- a/meshtastic/stream_interface.py +++ b/meshtastic/stream_interface.py @@ -104,7 +104,7 @@ class StreamInterface(MeshInterface): def _writeBytes(self, b: bytes) -> None: """Write an array of bytes to our stream and flush""" - if self.stream: # ignore writes when stream is closed + if self.stream and self.stream is not None and getattr(self.stream, "is_open", False): # ignore writes when stream is closed self.stream.write(b) self.stream.flush() # win11 might need a bit more time, too @@ -116,7 +116,7 @@ class StreamInterface(MeshInterface): def _readBytes(self, length) -> Optional[bytes]: """Read an array of bytes from our stream""" - if self.stream: + if self.stream and self.stream is not None and getattr(self.stream, "is_open", False): return self.stream.read(length) else: return None @@ -226,10 +226,12 @@ class StreamInterface(MeshInterface): logger.error( f"Unexpected OSError, terminating meshtastic reader... {ex}" ) + traceback.print_exc() except Exception as ex: logger.error( f"Unexpected exception, terminating meshtastic reader... {ex}" ) + traceback.print_exc() finally: logger.debug("reader is exiting") self._disconnected()