Python的控制器区域网络接口模块
项目描述
控制器局域网是一种总线标准,旨在允许微控制器和设备之间相互通信。它具有基于优先级的总线仲裁和可靠的确定通信。它被用于汽车、卡车、船只、轮椅等。
can 包为 Python 开发者提供了控制器局域网支持;提供对不同硬件设备的通用抽象,以及一套用于在 CAN 总线上发送和接收消息的实用工具。
该库目前支持 CPython 以及 PyPy,并在 Mac、Linux 和 Windows 上运行。
库版本 |
Python |
2.x |
2.6+, 3.4+ |
3.x |
2.7+, 3.5+ |
4.0+ |
3.7+ |
4.3+ |
3.8+ |
功能
示例用法
pip install python-can
# import the library
import can
# create a bus instance using 'with' statement,
# this will cause bus.shutdown() to be called on the block exit;
# many other interfaces are supported as well (see documentation)
with can.Bus(interface='socketcan',
channel='vcan0',
receive_own_messages=True) as bus:
# send a message
message = can.Message(arbitration_id=123, is_extended_id=True,
data=[0x11, 0x22, 0x33])
bus.send(message, timeout=0.2)
# iterate over received messages
for msg in bus:
print(f"{msg.arbitration_id:X}: {msg.data}")
# or use an asynchronous notifier
notifier = can.Notifier(bus, [can.Logger("recorded.log"), can.Printer()])
您可以在python-can.readthedocs.org上找到更多文档信息。
讨论
如果您遇到错误,可以在 GitHub 上的我们的问题跟踪器中提交。
Stackoverflow有几个带有python+can标签的问题和答案。
无论我们在哪里互动,我们都努力遵循Python 社区行为准则。
贡献
有关开始的信息,请参阅doc/development.rst。
项目详情
下载文件
下载适用于您平台的应用程序。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
python_can-4.4.2.tar.gz (345.6 kB 查看哈希值)
构建分布
python_can-4.4.2-py3-none-any.whl (265.2 kB 查看哈希值)
关闭
python_can-4.4.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1c46c0935f39f7a9c3e76b03249af0580689ebf7a1844195e92f87257f009df5 |
|
MD5 | 20133a1b73b58c976bba6b0af8581f32 |
|
BLAKE2b-256 | a31757c38abbf00993ac5ec306de0c00271685d1372ef3d907b107eb63ab13a8 |
关闭
python_can-4.4.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e956d781b45563c244c1f3c8fe001e292d1857519cff663d7c184673a68879f9 |
|
MD5 | ed28c6435705ea2958e6b99adcaeff5d |
|
BLAKE2b-256 | 42c59eb41131696edbe56c7b97e167e3c19b15bfa4f964e21c0a6c9f28bde298 |