OpenCyphal / pycyphal

Python implementation of the Cyphal protocol stack.
https://pycyphal.readthedocs.io/
MIT License
120 stars 105 forks source link

Add cantact interface #210

Closed chemicstry closed 2 years ago

chemicstry commented 2 years ago

This adds cantact interface from python-can

chemicstry commented 2 years ago

Note that python-can v4.0 is now released

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 42681491


Files with Coverage Reduction New Missed Lines %
/home/appveyor/projects/pyuavcan/pyuavcan/application/plug_and_play.py 1 92.56%
/home/appveyor/projects/pyuavcan/pyuavcan/transport/serial/_serial.py 2 92.36%
/home/appveyor/projects/pyuavcan/pyuavcan/transport/can/media/pythoncan/_pythoncan.py 43 67.01%
<!-- Total: 46 -->
Totals Coverage Status
Change from base Build 42632810: -0.06%
Covered Lines: 13670
Relevant Lines: 14146

💛 - Coveralls
chemicstry commented 2 years ago

I think the CI got stuck, but could you cancel the auto merge? I think the issue https://github.com/UAVCAN/yakut/issues/43 is related to the cantact driver in python-can, but I'm still investigating.

pavel-kirienko commented 2 years ago

Okay. Let me know how it goes.

chemicstry commented 2 years ago

So I've confirmed that there is a problem with cantact driver in python-can. For some reason it causes the python runtime to completely slow down, even exception traces are slow to print. I believe it messes things up somewhere in the FFI layer.

The alternative gs_usb driver in python-can also works with cantact adapters and so far it seems to work fine with pyuavcan/yakut. However, it has a very inconvenient API and requires USB bus/address to initialize, which changes on each USB enumeration. So in order to be "usable", pyuavcan would need usb dependency to do a lookup based on vid/pid, or I could submit a PR to python-can to add the scan function there instead.

I will close this PR for now.