hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.31k stars 604 forks source link

InnoMaker USB2CAN-X2 on a mac #1852

Closed c0g closed 2 months ago

c0g commented 2 months ago

This is the hardware: https://www.inno-maker.com/product/usb2can-x2-device/

I use socketcan on linux, trying to use it on my mac since I'll be traveling a bit. I've install python-can[gs_usb] (not sure if that's the right thing, but I saw some issues that indicated it might be).

I tried running detect_interfaces:

print(can.detect_available_configs(interfaces=None))
[{'interface': 'virtual', 'channel': 'channel-1601'}, {'interface': 'udp_multicast', 'channel': 'ff15:7079:7468:6f6e:6465:6d6f:6d63:6173'}, {'interface': 'udp_multicast', 'channel': '239.74.163.2'}]
print(can.detect_available_configs(interfaces=['gs_usb']))
[]
bus = can.interface.Bus(channel=0, interface='gs_usb', bitrate=1_000_000)
# can.exceptions.CanInitializationError: Cannot find device 0

I'm also looking at https://python-can.readthedocs.io/en/stable/interfaces/usb2can.html, but I think this currently works only on Windows. I'm wondering about blindly replacing the dll with libInnoMakerUSBIOLib.dylib from the mac client.

c0g commented 2 months ago

If I actually read the docs properly and try stuff out, it works fine.

bus0 = can.Bus(interface='gs_usb', channel='', index=0, bitrate=1_000_000, extended_id=True)

Channel doesn't seem to be required.