我正在尝试使用 Pythoncanopen
库和USB2CAN
适配器与canopen
402 设备进行通信。
到目前为止,我还没有理解定义网络的最基本示例。
脚本在错误上始终崩溃:
“AttributeError:‘Usb2canBus’对象没有属性‘_filters’”
python-can 的文档提到该设备没有实现过滤器usb2can
,但似乎暗示它应该仍然可用。
有没有人成功地将 usb2can 适配器与 Python 一起使用?
我找不到任何例子,有人可以指点我吗?
以下是 python canopen 文档中包含的非常基本的示例之一。
这会因上述过滤器错误而失败,我尝试过的大多数其他操作也是如此。
import canopen
import time
#define network
network = canopen.Network()
#establish connection
network.connect(channel='ED000200', bustype='usb2can', bitrate=500000)
# This will attempt to read an SDO from nodes 1 - 127
network.scanner.search()
# We may need to wait a short while here to allow all nodes to respond
time.sleep(0.05)
for node_id in network.scanner.nodes:
print("Found node %d!" % node_id)
#close connection
network.disconnect()
对于此示例,我希望打印网络上的节点列表,可能是一个空列表,因为没有添加任何节点。
相反,我收到了错误:
AttributeError:“Usb2canBus”对象没有属性“_filters”