【问题标题】:Python-can OSError: An address incompatible with the requested protocol was usedPython-can OSError:使用了与请求的协议不兼容的地址
【发布时间】:2019-01-21 15:14:05
【问题描述】:

我正在使用 CAN 电缆 ECOM,并尝试编写一个 python 脚本来处理从电缆接收到的消息。我遇到了python库python-can,但是我在使用它时遇到了麻烦。

当我尝试运行代码时:

import can
bus = can.interface.Bus(bustype='socketcan', channel='vcan0', bitrate=500000)

我明白了:

我在这个库中是否缺少导致问题的东西?

非常感谢您的热心帮助。

【问题讨论】:

    标签: python python-can


    【解决方案1】:

    解决了问题:SocketCan 在 Linux 系统上工作,我在 Windows 机器上。

    【讨论】:

      【解决方案2】:

      如果您通过 USB 在 Windows 上使用 PCAN,请使用以下参数:

      import can    
      bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
      

      您可以找到更多帮助here.

      希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-13
        • 2022-12-12
        • 1970-01-01
        • 2018-12-31
        相关资源
        最近更新 更多