python控制器局域网接口模块
python-can的Python项目详细描述
cc ontrollerarean网络是设计的总线标准 允许微控制器和设备相互通信。它 具有基于优先级的总线仲裁和可靠的确定性 沟通。它被用于汽车、卡车、船只、轮椅等。
can包为 python开发人员;为 不同的硬件设备,以及一套用于发送和接收的实用程序 can总线上的信息。
该库支持Python2.7、Python3.5+以及PyPy2&3并运行 在Mac、Linux和Windows上。
Library Version | Python |
2.x | 2.6+, 3.4+ |
3.x | 2.7+, 3.5+ |
4.x (expected) | 3.6+ |
功能
示例用法
# import the libraryimportcan# create a bus instance# many other interfaces are supported as well (see below)bus=can.Bus(interface='socketcan',channel='vcan0',receive_own_messages=True)# send a messagemessage=can.Message(arbitration_id=123,is_extended_id=True,data=[0x11,0x22,0x33])bus.send(message,timeout=0.2)# iterate over received messagesformsginbus:print("{X}: {}".format(msg.arbitration_id,msg.data))# or use an asynchronous notifiernotifier=can.Notifier(bus,[can.Logger("recorded.log"),can.Printer()])
您可以在文档中找到更多信息,在线 python-can.readthedocs.org。
讨论
如果你遇到了错误,你可以把它们归档到 issue tracker在github上。
还有一个python-can 用于开发讨论的邮件列表。
Stackoverflow有几个 用python+can标记的问题和答案。
无论我们在哪里交流,我们都会努力遵循 Python Community Code of Conduct。
贡献
请参见doc/development.rst了解入门信息。