python-can-hirain-test 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_can_hirain_test-0.1.1/LICENSE +26 -0
- python_can_hirain_test-0.1.1/PKG-INFO +83 -0
- python_can_hirain_test-0.1.1/README.md +68 -0
- python_can_hirain_test-0.1.1/pyproject.toml +34 -0
- python_can_hirain_test-0.1.1/setup.cfg +4 -0
- python_can_hirain_test-0.1.1/src/can_hirain/BasicStructure.py +1661 -0
- python_can_hirain_test-0.1.1/src/can_hirain/TestBaseVCI.py +1084 -0
- python_can_hirain_test-0.1.1/src/can_hirain/__init__.py +3 -0
- python_can_hirain_test-0.1.1/src/can_hirain/hrcan.py +655 -0
- python_can_hirain_test-0.1.1/src/demo/Test_Canfd.py +112 -0
- python_can_hirain_test-0.1.1/src/demo/Test_can.py +81 -0
- python_can_hirain_test-0.1.1/src/demo/Test_diag.py +87 -0
- python_can_hirain_test-0.1.1/src/demo/Test_env.py +2 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/PKG-INFO +83 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/SOURCES.txt +17 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/dependency_links.txt +1 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/entry_points.txt +2 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/requires.txt +1 -0
- python_can_hirain_test-0.1.1/src/python_can_hirain_test.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 JINGWEI HIRAIN
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
Third-party libraries imported in the code are subject to the proprietary rights
|
|
16
|
+
notices of their respective authors. Users must comply with the copyright
|
|
17
|
+
requirements specified by the authors of such third-party libraries.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-can-hirain-test
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: python-can interface plugin for Hirain
|
|
5
|
+
Author-email: Jingwei Hirain <yalong.ding@hirain.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: python-can,CAN,Hirain
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: python-can>=4.0.0
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# python-can-hirain
|
|
17
|
+
|
|
18
|
+
Python CAN 接口适配器,用于通过 **python-can** 库操作 **HIRAIN TestBaseVCI** 硬件设备。
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
使用 pip 安装:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install python-can-hirain
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
安装后,`hrcan` 接口会自动注册到 python-can 中,无需手动复制文件或修改 `__init__.py`。
|
|
29
|
+
|
|
30
|
+
## 快速开始
|
|
31
|
+
|
|
32
|
+
### CAN 通信示例
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import can
|
|
36
|
+
import time
|
|
37
|
+
|
|
38
|
+
# 初始化 CAN 通道
|
|
39
|
+
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
|
|
40
|
+
configs = [{
|
|
41
|
+
'resistance': 1, # 启用终端电阻
|
|
42
|
+
'mode' : TestBaseVCI_ChlMode.CAN, # 设置CAN通道
|
|
43
|
+
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
|
|
44
|
+
'baudrate': 500_000,
|
|
45
|
+
'samplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_75}]) as bus:
|
|
46
|
+
pass
|
|
47
|
+
# 初始化 CANFD 通道
|
|
48
|
+
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
|
|
49
|
+
configs = [{
|
|
50
|
+
'resistance': 1, # 启用终端电阻
|
|
51
|
+
'mode' : TestBaseVCI_ChlMode.CANFD, # 设置CANFD通道
|
|
52
|
+
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
|
|
53
|
+
'abrBaudrate': 500_000,
|
|
54
|
+
'dbrBaudrate': 2000_000,
|
|
55
|
+
'abrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,
|
|
56
|
+
'dbrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,}]) as bus:
|
|
57
|
+
pass
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## 环境要求
|
|
62
|
+
|
|
63
|
+
- **操作系统**: Windows 10/11, Ubuntu 20/22
|
|
64
|
+
- **硬件驱动**: TestBaseVCI 驱动程序 2.4.1+
|
|
65
|
+
- **Python**: 64 位 Python 3.7+
|
|
66
|
+
- **依赖库**: python-can
|
|
67
|
+
|
|
68
|
+
## 更多示例
|
|
69
|
+
|
|
70
|
+
查看 `demo/` 目录获取完整示例:
|
|
71
|
+
- `Test_can.py` - 经典 CAN 操作示例
|
|
72
|
+
- `Test_Canfd.py` - CAN FD 操作示例
|
|
73
|
+
- `Test_diag.py` - 诊断功能示例
|
|
74
|
+
|
|
75
|
+
## 注意事项
|
|
76
|
+
|
|
77
|
+
- 确保 TestBaseVCI 驱动程序已正确安装
|
|
78
|
+
- Linux 系统上使用 sudo 时,可能需要添加 `-E` 参数保留环境变量
|
|
79
|
+
- 使用前请确认设备能被系统识别
|
|
80
|
+
|
|
81
|
+
## 支持
|
|
82
|
+
|
|
83
|
+
有关详细配置参数和高级用法,请参考 python-can 官方文档和 HIRAIN 二次开发SDK手册。
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# python-can-hirain
|
|
2
|
+
|
|
3
|
+
Python CAN 接口适配器,用于通过 **python-can** 库操作 **HIRAIN TestBaseVCI** 硬件设备。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
使用 pip 安装:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install python-can-hirain
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
安装后,`hrcan` 接口会自动注册到 python-can 中,无需手动复制文件或修改 `__init__.py`。
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
### CAN 通信示例
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import can
|
|
21
|
+
import time
|
|
22
|
+
|
|
23
|
+
# 初始化 CAN 通道
|
|
24
|
+
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
|
|
25
|
+
configs = [{
|
|
26
|
+
'resistance': 1, # 启用终端电阻
|
|
27
|
+
'mode' : TestBaseVCI_ChlMode.CAN, # 设置CAN通道
|
|
28
|
+
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
|
|
29
|
+
'baudrate': 500_000,
|
|
30
|
+
'samplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_75}]) as bus:
|
|
31
|
+
pass
|
|
32
|
+
# 初始化 CANFD 通道
|
|
33
|
+
with can.Bus(interface="hrcan", channel=0, # 激活通道0为CANFD通道
|
|
34
|
+
configs = [{
|
|
35
|
+
'resistance': 1, # 启用终端电阻
|
|
36
|
+
'mode' : TestBaseVCI_ChlMode.CANFD, # 设置CANFD通道
|
|
37
|
+
'listenFlag' : 0, # 0-正常状态,1-通道为仅监听状态,不给ACK响应
|
|
38
|
+
'abrBaudrate': 500_000,
|
|
39
|
+
'dbrBaudrate': 2000_000,
|
|
40
|
+
'abrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,
|
|
41
|
+
'dbrSamplePoint': TestBaseVCI_SAMPLEPOINT.SAMPLE_80,}]) as bus:
|
|
42
|
+
pass
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## 环境要求
|
|
47
|
+
|
|
48
|
+
- **操作系统**: Windows 10/11, Ubuntu 20/22
|
|
49
|
+
- **硬件驱动**: TestBaseVCI 驱动程序 2.4.1+
|
|
50
|
+
- **Python**: 64 位 Python 3.7+
|
|
51
|
+
- **依赖库**: python-can
|
|
52
|
+
|
|
53
|
+
## 更多示例
|
|
54
|
+
|
|
55
|
+
查看 `demo/` 目录获取完整示例:
|
|
56
|
+
- `Test_can.py` - 经典 CAN 操作示例
|
|
57
|
+
- `Test_Canfd.py` - CAN FD 操作示例
|
|
58
|
+
- `Test_diag.py` - 诊断功能示例
|
|
59
|
+
|
|
60
|
+
## 注意事项
|
|
61
|
+
|
|
62
|
+
- 确保 TestBaseVCI 驱动程序已正确安装
|
|
63
|
+
- Linux 系统上使用 sudo 时,可能需要添加 `-E` 参数保留环境变量
|
|
64
|
+
- 使用前请确认设备能被系统识别
|
|
65
|
+
|
|
66
|
+
## 支持
|
|
67
|
+
|
|
68
|
+
有关详细配置参数和高级用法,请参考 python-can 官方文档和 HIRAIN 二次开发SDK手册。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-can-hirain-test"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "python-can interface plugin for Hirain"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Jingwei Hirain", email = "yalong.ding@hirain.com" }]
|
|
13
|
+
keywords = ["python-can", "CAN", "Hirain"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"python-can>=4.0.0",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
# Homepage = "https://github.com/yourname/python-can-mydevice"
|
|
24
|
+
# Issues = "https://github.com/yourname/python-can-mydevice/issues"
|
|
25
|
+
|
|
26
|
+
# 关键:注册给 python-can
|
|
27
|
+
[project.entry-points."can.interface"]
|
|
28
|
+
hrcan = "can_hirain.hrcan:HRCANBus"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools]
|
|
31
|
+
package-dir = {"" = "src"}
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
where = ["src"]
|