You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering this error when an ESP32 device is unplugged at the usb connector.
Background: Initial serial connection was established using esptool.py, which used pyserial. I wrote a method to do certain actions when connection to the serial port is lost and not break my apprication. Below shows the error msgs:
Traceback (most recent call last):
File "~/Esp32/test.py", line 291, in _check_connection
self.esp.flush_input()
File "~/.local/share/virtualenvs/Esp32-zoIgntnu/bin/esptool.py", line 392, in flush_input
self._port.flushInput()
File "~/.local/share/virtualenvs/Esp32-zoIgntnu/lib/python3.6/site-packages/serial/serialutil.py", line 584, in flushInput
self.reset_input_buffer()
File "~/.local/share/virtualenvs/Esp32-zoIgntnu/lib/python3.6/site-packages/serial/serialposix.py", line 595, in reset_input_buffer
termios.tcflush(self.fd, termios.TCIFLUSH)
termios.error: (5, 'Input/output error')
Part of my monitoring method:
def _check_connection( self ):
print('\ndef _check_connection( self ):')
if self._connected:
try:
self.esp.flush_input()
except SerialException as e:
self._connected = False
print( 'SerialException: ', e )
except TypeError as e:
self._connected = False
self.esp._port.close()
print( 'TypeError: ', e )
else:
print( 'Read! ' )
self.after( 5000, self._check_connection ) # Check connection every 5s.
Assessment: I think both serialposix.py and esptool.py should execute lines 595 and 584, respectively, in a "try-except" statement and raise a SerialException so that users can gracefully handle error relating to disconnected serial port. I have communicated this matter to esptool.py and it's maintainer suggested I alert pyserial maintainer on this issue.
The text was updated successfully, but these errors were encountered:
I am encountering this error when an ESP32 device is unplugged at the usb connector.
Background: Initial serial connection was established using esptool.py, which used pyserial. I wrote a method to do certain actions when connection to the serial port is lost and not break my apprication. Below shows the error msgs:
Part of my monitoring method:
Assessment: I think both serialposix.py and esptool.py should execute lines 595 and 584, respectively, in a "try-except" statement and raise a
SerialException
so that users can gracefully handle error relating to disconnected serial port. I have communicated this matter to esptool.py and it's maintainer suggested I alert pyserial maintainer on this issue.The text was updated successfully, but these errors were encountered: