RFC2217 and pyserial-asyncio
Trying to connect to remote serial port served by ser2net with pyserial-asyncio. Fails due to error:
NotImplementedError: write_timeout is currently not supported
Trace:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../nextion/client.py:53: in connect
_, self.connection = await serial_asyncio.create_serial_connection(loop, self.make_protocol, url=self.url, baudrate=self.baudrate)
/usr/lib/python3.6/asyncio/coroutines.py:212: in coro
res = func(*args, **kw)
/usr/local/lib/python3.6/dist-packages/serial_asyncio/__init__.py:412: in create_serial_connection
transport = SerialTransport(loop, protocol, ser)
/usr/local/lib/python3.6/dist-packages/serial_asyncio/__init__.py:64: in __init__
self._serial.write_timeout = 0
/usr/lib/python3/dist-packages/serial/serialutil.py:388: in write_timeout
self._reconfigure_port()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Serial<id=0x7f37b3c5f2e8, open=True>(port='rfc2217://192.168.1.2:1900', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False)
def _reconfigure_port(self):
"""Set communication parameters on opened port."""
if self._socket is None:
raise SerialException("Can only operate on open ports")
# if self._timeout != 0 and self._interCharTimeout is not None:
# XXX
if self._write_timeout is not None:
> raise NotImplementedError('write_timeout is currently not supported')
E NotImplementedError: write_timeout is currently not supported
/usr/lib/python3/dist-packages/serial/rfc2217.py:506: NotImplementedError
pyserial-asyncio sets write timeout here: https://github.com/pyserial/pyserial-asyncio/blob/cf256c6a7202f2f2ac422236fdb036609385de05/serial_asyncio/init.py#L65
Similar issue on pyserial side: https://github.com/pyserial/pyserial/issues/412
@rob-smallshire @zsquareplusc would you accept a pull to remove this line? From what you can tell is that all that is needed to fix this issue? (sorry if I @'d the wrong people!) Should this line only be omitted for rfc2217?
OK, commented out that line but it looks like there's more to be done here:
Error doing job: Exception in callback SerialTransport._ensure_reader()
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/events.py", line 126, in _run
self._callback(*self._args)
File "/opt/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 304, in _ensure_reader
self._loop.add_reader(self._serial.fileno(), self._read_ready)
io.UnsupportedOperation: fileno