mirror of
https://github.com/meshtastic/python.git
synced 2025-12-29 19:07:57 -05:00
refactor flush
The double flush() is not the root cause; the real issue is that code is trying to use the serial port after it has been closed. The error occurs both in close() (during flush()) and later in _writeBytes() (during write()), indicating the port is closed or invalid at those times.
This commit is contained in:
@@ -89,10 +89,12 @@ class SerialInterface(StreamInterface):
|
||||
try:
|
||||
self.stream.flush()
|
||||
time.sleep(0.1)
|
||||
# FIXME: why are there these two flushes with 100ms sleeps? This shouldn't be necessary
|
||||
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
|
||||
logger.debug("Closing Serial stream")
|
||||
StreamInterface.close(self)
|
||||
|
||||
Reference in New Issue
Block a user