Open
Description
Per Pyserial URL Handlers documentation it's useful to have a loop://
handler. In unit testing I've used this extensively for simple testing. This avoids having to setup a TCP socket server as done in #1 .
Would it be possible to better support this? My hunch is this has something to do with how pyserial
handles the loop://
functionality and it may not work well with asyncio
.
Tests
Running the base pyserial-asyncio
boilerplate code with loop://
shown below:
loop = asyncio.get_event_loop()
coro = serial_asyncio.create_serial_connection(loop, faraday.Output, 'loop://', baudrate=115200)
loop.run_until_complete(coro)
loop.run_forever()
loop.close()
Results in the following output which is missing the "Hello, world" text that is expected (using pytest
):
(.venv) bryce@bryce-ubuntu:~/Documents/git/faradayio$ sudo .venv/bin/python3 -m pytest -sk serialAsyncio
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
rootdir: /home/bryce/Documents/git/faradayio, inifile:
plugins: cov-2.5.1
collecting 34 items WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6
collected 39 items
tests/test_serial.py port opened SerialTransport(<_UnixSelectorEventLoop running=True closed=False debug=False>, <faradayio.faraday.Output object at 0x7f571ca91b00>, Serial<id=0x7f571ca91b38, open=True>(port='loop://', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))
port closed
.
============================= 38 tests deselected ==============================
=================== 1 passed, 38 deselected in 0.38 seconds ====================
Yet the same code using a loopback hardware serial device on /dev/ttyUSB0
results in:
=================== 1 passed, 38 deselected in 0.40 seconds ====================
(.venv) bryce@bryce-ubuntu:~/Documents/git/faradayio$ sudo .venv/bin/python3 -m pytest -sk serialAsyncio
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
rootdir: /home/bryce/Documents/git/faradayio, inifile:
plugins: cov-2.5.1
collecting 34 items WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6
collected 39 items
tests/test_serial.py port opened SerialTransport(<_UnixSelectorEventLoop running=True closed=False debug=False>, <faradayio.faraday.Output object at 0x7ff7bcb159e8>, Serial<id=0x7ff7c248c6a0, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))
data received b'Hello, World!\n'
port closed
.
============================= 38 tests deselected ==============================
=================== 1 passed, 38 deselected in 0.38 seconds ====================
Metadata
Metadata
Assignees
Labels
No labels