Skip to content

RFC2217 and pyserial-asyncio #46

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
yozik04 opened this issue Aug 4, 2019 · 2 comments
Open

RFC2217 and pyserial-asyncio #46

yozik04 opened this issue Aug 4, 2019 · 2 comments

Comments

@yozik04
Copy link

yozik04 commented Aug 4, 2019

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:

self._serial.write_timeout = 0

Similar issue on pyserial side: pyserial/pyserial#412

@DaAwesomeP
Copy link

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

@DaAwesomeP
Copy link

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants