Как на Python подключиться к модулю 2515 по can-шине?
Вот код:
from __future__ import print_function
import can
bus = can.interface.Bus(channel='can0', bustype='socketcan_native') #согласование модуля и Raspberry
bitrate = 100000
def send_one():
#bus = can.interface.Bus()
msg = can.Message(arbitration_id=0,
data=[67, 10, 100, 0, 0, 0, 0, 0],
extended_id=False)
try:
bus.send(msg)
print("Message sent on {}".format(bus.channel_info))
except can.CanError:
print("Message NOT sent")
def main():
while True:
os.system(
"sudo /sbin/ip link set can0 up type can bitrate {0}".format(bitrate)
) #настройка CAN через консоль Linux
try:
#recv_begin()
send_one()
except can.CanError:
print("Don't work")
if __name__ == "__main__":
main()
Отправляющее устройство - Raspberry Pi 2. Использую пакет python-can, но выбивает ошибки:
Traceback (most recent call last):
File "/home/pi/Desktop/CAN/CAN.py", line 4, in <module>
bus = can.interface.Bus(channel='can0', bustype='socketcan_native') #согласование модуля и Raspberry
File "/usr/local/lib/python3.4/dist-packages/python_can-1.4.1-py3.4.egg/can/interfaces/interface.py", line 54, in __new__
return cls(channel, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/python_can-1.4.1-py3.4.egg/can/interfaces/socketcan_native.py", line 296, in __init__
bindSocket(self.socket, channel)
File "/usr/local/lib/python3.4/dist-packages/python_can-1.4.1-py3.4.egg/can/interfaces/socketcan_native.py", line 200, in bindSocket
sock.bind((channel,))
OSError: [Errno 19] No such device
Раньше все работало
Библиотеку изменили?