trying to use spy:// (pyserial feature) with Interface mistakes it for a host address
Closed this issue · 3 comments
using SerialInterface instead works fine.
pyserial supports telnet & socket connections as well as specifying device properties directly with hwgrep
https://pyserial.readthedocs.io/en/latest/url_handlers.html
can't say what the best approach is, but spy:// is very handy and could cause some confusion
Traceback (most recent call last):
File "./rpctest.py", line 6, in <module>
i = Interface("spy:///dev/ttyUSB0", 9600)
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 235, in __new__
return SocketInterface(device, *args, **kwargs)
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 190, in __init__
self.open()
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 196, in _auto_open_wrapper
result = f(self, *args, **kwargs)
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 210, in open
super().open()
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 105, in open
self.methods = self._get_methods()
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 82, in _get_methods
if self._read_byte_string() != _protocol:
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/simple_rpc.py", line 64, in _read_byte_string
return read_byte_string(self._connection)
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/io.py", line 90, in read_byte_string
return _read_bytes_until(stream, _end_of_string)
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/io.py", line 15, in _read_bytes_until
return b''.join(until(lambda x: x == delimiter, stream.read, 1))
File "/home/ohsix/.local/lib/python3.8/site-packages/simple_rpc/io.py", line 120, in until
result = f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/serial/urlhandler/protocol_spy.py", line 205, in read
rx = super(Serial, self).read(size)
File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 483, in read
ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
KeyboardInterrupt
thanks! this library is very useful
Thank you for raising this issue. I think there may be a timeout problem here. Could you perhaps try the following?
from time import sleep
i = Interface("spy:///dev/ttyUSB0", 9600, autoconnect=False)
sleep(2)
i.open()
that is what I thought initially, and what got me to come to github, but then I noticed SocketInterface in the backtrace after I pasted it in, and remembered that the library used a colon to decide whether to use SerialInterface or SocketInterface
if I use SerialInterface("spy://....") directly it works fine
Thanks for the additional information. Can you try the latest version?
Please reopen the ticket if this did not solve the problem.