连接can
can0 = can.interface.Bus(channel = ‘can0’, bustyp = ‘socketcan_ctypes’)
在python中连接can是会出现下列错误:
/
Traceback (most recent call last): File “recv.py”, line 10, in can1 = can.interface.Bus(channel = ‘can1’, bustyp = ‘socketcan_ctypes’) File “/usr/local/lib/python3.7/dist-packages/can/interface.py”, line 108, in new kwargs = load_config(config=kwargs, context=context) File “/usr/local/lib/python3.7/dist-packages/can/util.py”, line 197, in load_config raise NotImplementedError(‘Invalid CAN Bus Type - {}’.format(config[‘interface’])) NotImplementedError: Invalid CAN Bus Type - None
解决方法:
在~/下添加 .canrc文件,
sudo vi ~/.canrc
里面填写如下信息
/
[default] interface = socketcan channel = can0
问题即可解决