首页 > 解决方案 > 尝试通过 Peak USB 从 Python 向 BUSMASTER 发送消息

问题描述

这是代码---

from __future__ import print_function
import can

def send_one():
    bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000,state = can.bus.BusState.PASSIVE
)

    msg = can.Message(arbitration_id=0xc0ffee,
                      data=[0, 25, 0, 1, 3, 1, 4, 1],
                      extended_id=True)
    try:
        bus.send(msg)
        print("Message sent on {}".format(bus.channel_info))
    except can.CanError:
        print("Message NOT sent")

if __name__ == '__main__':
    send_one()

我收到OS错误,我尝试安装openslide但没有导入。请帮忙

标签: python

解决方案


推荐阅读