我尝试使用Python canopen
库和USB2CAN
适配器与canopen
402设备通信。在
到目前为止,我还不能通过定义网络的最基本的例子。在
出现错误时脚本始终崩溃:
"AttributeError: 'Usb2canBus' object has no attribute '_filters' "
python的文档可以提到,过滤器不是为usb2can
设备实现的,但似乎暗示它应该仍然可用。在
是否有人成功地将usb2can适配器与Python一起使用?在
我找不到任何例子,有人能给我举一个吗?在
下面是pythoncanopen文档中包含的一个非常基本的示例。在
这会因为上面描述的过滤器错误而失败,就像我尝试过的大多数其他操作一样。在
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' object has no attribute '_filters'
目前没有回答
相关问题 更多 >
编程相关推荐