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:
SpudGunMan
2025-10-14 07:54:37 -07:00
parent 93da1da386
commit da416fcd20

View File

@@ -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)