python-can interface plugin for Hirain
Project description
python-can-hirain
Python CAN 接口适配器,用于通过 python-can 库操作 HIRAIN TestBaseVCI 硬件设备。
安装
使用 pip 安装:
pip install python-can-hirain
安装后,hrcan 接口会自动注册到 python-can 中,无需手动复制文件或修改 __init__.py。
快速开始
CAN 通信示例
import can
import time
# 初始化 CAN 通道
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
configs = [{
'resistance': 1, # 启用终端电阻
'mode' : TestBaseVCI_ChlMode.CAN, # 设置CAN通道
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
'baudrate': 500_000,
'samplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_75}]) as bus:
pass
# 初始化 CANFD 通道
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
configs = [{
'resistance': 1, # 启用终端电阻
'mode' : TestBaseVCI_ChlMode.CANFD, # 设置CANFD通道
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
'abrBaudrate': 500_000,
'dbrBaudrate': 2000_000,
'abrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,
'dbrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,}]) as bus:
pass
环境要求
- 操作系统: Windows 10/11, Ubuntu 20/22
- 硬件驱动: TestBaseVCI 驱动程序 2.4.1+
- Python: 64 位 Python 3.7+
- 依赖库: python-can
更多示例
查看 demo/ 目录获取完整示例:
Test_can.py- 经典 CAN 操作示例Test_Canfd.py- CAN FD 操作示例Test_diag.py- 诊断功能示例
注意事项
- 确保 TestBaseVCI 驱动程序已正确安装
- Linux 系统上使用 sudo 时,可能需要添加
-E参数保留环境变量 - 使用前请确认设备能被系统识别
支持
有关详细配置参数和高级用法,请参考 python-can 官方文档和 HIRAIN 二次开发SDK手册。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_can_hirain-0.2.1.tar.gz
(42.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_can_hirain-0.2.1.tar.gz.
File metadata
- Download URL: python_can_hirain-0.2.1.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4a62df9a112127e692bd96509581f690e3112aa49862c57b9bd6f02b7159334
|
|
| MD5 |
a9ef3348e496738451e5637e089cf0bc
|
|
| BLAKE2b-256 |
7d52214718ce574f6c68884a2a1edad90aab7c4e9e70b14f3dd3743353554e6b
|
File details
Details for the file python_can_hirain-0.2.1-py3-none-any.whl.
File metadata
- Download URL: python_can_hirain-0.2.1-py3-none-any.whl
- Upload date:
- Size: 44.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1db92d7d5d204ed0f2eed0614f0562e58b0f75dba26a5dd0e9bb9a2e47ac1a29
|
|
| MD5 |
a084433bf40cce276c9a2b227581caab
|
|
| BLAKE2b-256 |
43132bce5be24e7ba6ce94be4ac2bb6bff90bb6c7f0ad909efb9a325d5f98fdb
|