zlgcan 0.1.17__tar.gz → 0.2.0__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.
@@ -93,8 +93,8 @@ jobs:
93
93
  - name: Publish to PyPI
94
94
  uses: PyO3/maturin-action@v1
95
95
  env:
96
- MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
96
+ MATURIN_PYPI_TOKEN: ${{ secrets.ZLGCAN_TOKEN }}
97
97
  with:
98
- token: ${{ secrets.PYPI_TOKEN }}
98
+ token: ${{ secrets.ZLGCAN_TOKEN }}
99
99
  command: upload
100
100
  args: --non-interactive --skip-existing wheels-*/*
@@ -60,12 +60,6 @@ dependencies = [
60
60
  "syn",
61
61
  ]
62
62
 
63
- [[package]]
64
- name = "dotenvy"
65
- version = "0.15.7"
66
- source = "registry+https://github.com/rust-lang/crates.io-index"
67
- checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
68
-
69
63
  [[package]]
70
64
  name = "equivalent"
71
65
  version = "1.0.2"
@@ -86,9 +80,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
86
80
 
87
81
  [[package]]
88
82
  name = "indexmap"
89
- version = "2.8.0"
83
+ version = "2.9.0"
90
84
  source = "registry+https://github.com/rust-lang/crates.io-index"
91
- checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
85
+ checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
92
86
  dependencies = [
93
87
  "equivalent",
94
88
  "hashbrown",
@@ -222,9 +216,9 @@ dependencies = [
222
216
 
223
217
  [[package]]
224
218
  name = "rs-can"
225
- version = "0.2.0"
219
+ version = "0.2.2"
226
220
  source = "registry+https://github.com/rust-lang/crates.io-index"
227
- checksum = "4416620ec3f2141f73b5d0936481c9caf3aa27ba140e2a97f178b80b7f110f68"
221
+ checksum = "7deea04551200cab94e5f3faf27be4ad02f84138db280630aa8f3b0b6bcb29ed"
228
222
  dependencies = [
229
223
  "bitflags",
230
224
  "derive-getters",
@@ -351,12 +345,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
351
345
 
352
346
  [[package]]
353
347
  name = "zlgcan"
354
- version = "0.2.0"
348
+ version = "0.2.2"
355
349
  source = "registry+https://github.com/rust-lang/crates.io-index"
356
- checksum = "ad37441e238647c26ae9521b03bfb3abf3dbd37c74ac4f47219a624781b71f7a"
350
+ checksum = "2c4aa30b676bf4cb84f707cba8a8336585d8028bdcf4daaf87ca30bfaf233589"
357
351
  dependencies = [
358
352
  "dlopen2",
359
- "dotenvy",
360
353
  "log",
361
354
  "rs-can",
362
355
  "serde",
@@ -365,7 +358,7 @@ dependencies = [
365
358
 
366
359
  [[package]]
367
360
  name = "zlgcan-driver"
368
- version = "0.1.17"
361
+ version = "0.2.0"
369
362
  dependencies = [
370
363
  "anyhow",
371
364
  "pyo3",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "zlgcan-driver"
3
- version = "0.1.17"
3
+ version = "0.2.0"
4
4
  edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -13,8 +13,8 @@ pyo3 = "0.24"
13
13
  #iso15765-2 = { version = "0.1.0-alpha0" }
14
14
  #iso14229-1 = { version = "0.1.0-alpha0" }
15
15
  #docan = { version = "0.1.0-alpha0" }
16
- rs-can = { version = "0.2.0" }
17
- zlgcan = { version = "0.2.0" }
16
+ rs-can = "0.2.2"
17
+ zlgcan = "0.2.2"
18
18
 
19
19
  [dev-dependencies]
20
20
  anyhow = "1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zlgcan
3
- Version: 0.1.17
3
+ Version: 0.2.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -23,39 +23,26 @@ Project-URL: repository, https://github.com/zhuyu4839/zlgcan-driver
23
23
  * 确保安装相关驱动(USBCAN-I/II驱动得额外安装)
24
24
  * 确保安装相[VC++运行环境](https://manual.zlg.cn/web/#/152?page_id=5332)
25
25
  * 下载[library](https://github.com/zhuyu4839/rust-can/tree/master/zlgcan/library)文件夹(里面包含[bitrate.cfg.yaml](https://github.com/zhuyu4839/rust-can/tree/master/zlgcan/library/bitrate.cfg.yaml))
26
- * 在当前工程目录下(相对运行脚本)新建一个`zcan.env`文件, 中间配置`ZCAN_LIBRARY`环境变量(相对路径/绝对路径),否则使用默认(相对运行脚本)路径:
27
- * 默认(相对运行脚本)路径文件夹内容示例:
26
+ * 库文件示例:
28
27
  ```shell
29
- ├─main.py
30
- ├─library
31
- ├──linux
32
- │ │ └─x86_64
33
- │ └─windows
34
- │ ├─x86
35
- │ └─x86_64
36
- └─ bitrate.cfg.yaml
37
- ```
38
- * (相对运行脚本)`zcan.env`文件指定`library`示例:
39
- ```shell
40
- ├─main.py
41
- ├─zcan.env
42
- └─library
43
- ├─linux
44
- │ └─x86_64
45
- ├─windows
46
- │ ├─x86
28
+ library
29
+ ├──bitrate.cfg.yaml
30
+ ├──linux
47
31
  │ └─x86_64
48
- └─ bitrate.cfg.yaml
32
+ └─windows
33
+ ├─x86
34
+ └─x86_64
35
+ ```
36
+ * 在初始化can.Bus的时候指定zlgcan库路径(从0.2.0开始移除`zcan.env`配置), 默认为相对工程运行文件同级目录下`library`
37
+ ```python
38
+ libpath=r"C:\your\library\path"
49
39
  ```
50
- * 以下为`zcan.env`文件内容示例
51
- ```shell
52
- ZCAN_LIBRARY="C:/your_library_path"
53
- ```
54
40
 
55
- 2. 安装zlgcan-driver-py(不建议使用低于0.1.10版本)
41
+ 2. 安装zlgcan(不建议使用低于0.2.0版本)
56
42
 
57
43
  ```shell
58
- pip install zlgcan >= 0.1.10
44
+ pip install zlgcan >= 0.2.0
45
+ ```
59
46
 
60
47
  3. 使用:
61
48
  ```python
@@ -63,6 +50,7 @@ Project-URL: repository, https://github.com/zhuyu4839/zlgcan-driver
63
50
  from zlgcan.zlgcan import ZCanTxMode, ZCANDeviceType
64
51
 
65
52
  with can.Bus(interface="zlgcan", device_type=ZCANDeviceType.ZCAN_USBCANFD_200U,
53
+ libpath="library/",
66
54
  configs=[{'bitrate': 500000, 'resistance': 1}, {'bitrate': 500000, 'resistance': 1}]) as bus:
67
55
  bus.send(can.Message(
68
56
  arbitration_id=0x123,
@@ -75,6 +63,7 @@ Project-URL: repository, https://github.com/zhuyu4839/zlgcan-driver
75
63
  # time.sleep(0.1)
76
64
  _msg = bus.recv()
77
65
  print(_msg)
66
+ ```
78
67
 
79
68
  4. CAN测试列表:
80
69
  * USBCAN-I-mini - ZCAN_USBCAN1, ZCAN_USBCAN2
@@ -7,39 +7,26 @@
7
7
  * 确保安装相关驱动(USBCAN-I/II驱动得额外安装)
8
8
  * 确保安装相[VC++运行环境](https://manual.zlg.cn/web/#/152?page_id=5332)
9
9
  * 下载[library](https://github.com/zhuyu4839/rust-can/tree/master/zlgcan/library)文件夹(里面包含[bitrate.cfg.yaml](https://github.com/zhuyu4839/rust-can/tree/master/zlgcan/library/bitrate.cfg.yaml))
10
- * 在当前工程目录下(相对运行脚本)新建一个`zcan.env`文件, 中间配置`ZCAN_LIBRARY`环境变量(相对路径/绝对路径),否则使用默认(相对运行脚本)路径:
11
- * 默认(相对运行脚本)路径文件夹内容示例:
10
+ * 库文件示例:
12
11
  ```shell
13
- ├─main.py
14
- ├─library
15
- ├──linux
16
- │ │ └─x86_64
17
- │ └─windows
18
- │ ├─x86
19
- │ └─x86_64
20
- └─ bitrate.cfg.yaml
21
- ```
22
- * (相对运行脚本)`zcan.env`文件指定`library`示例:
23
- ```shell
24
- ├─main.py
25
- ├─zcan.env
26
- └─library
27
- ├─linux
28
- │ └─x86_64
29
- ├─windows
30
- │ ├─x86
12
+ library
13
+ ├──bitrate.cfg.yaml
14
+ ├──linux
31
15
  │ └─x86_64
32
- └─ bitrate.cfg.yaml
16
+ └─windows
17
+ ├─x86
18
+ └─x86_64
19
+ ```
20
+ * 在初始化can.Bus的时候指定zlgcan库路径(从0.2.0开始移除`zcan.env`配置), 默认为相对工程运行文件同级目录下`library`
21
+ ```python
22
+ libpath=r"C:\your\library\path"
33
23
  ```
34
- * 以下为`zcan.env`文件内容示例
35
- ```shell
36
- ZCAN_LIBRARY="C:/your_library_path"
37
- ```
38
24
 
39
- 2. 安装zlgcan-driver-py(不建议使用低于0.1.10版本)
25
+ 2. 安装zlgcan(不建议使用低于0.2.0版本)
40
26
 
41
27
  ```shell
42
- pip install zlgcan >= 0.1.10
28
+ pip install zlgcan >= 0.2.0
29
+ ```
43
30
 
44
31
  3. 使用:
45
32
  ```python
@@ -47,6 +34,7 @@
47
34
  from zlgcan.zlgcan import ZCanTxMode, ZCANDeviceType
48
35
 
49
36
  with can.Bus(interface="zlgcan", device_type=ZCANDeviceType.ZCAN_USBCANFD_200U,
37
+ libpath="library/",
50
38
  configs=[{'bitrate': 500000, 'resistance': 1}, {'bitrate': 500000, 'resistance': 1}]) as bus:
51
39
  bus.send(can.Message(
52
40
  arbitration_id=0x123,
@@ -59,6 +47,7 @@
59
47
  # time.sleep(0.1)
60
48
  _msg = bus.recv()
61
49
  print(_msg)
50
+ ```
62
51
 
63
52
  4. CAN测试列表:
64
53
  * USBCAN-I-mini - ZCAN_USBCAN1, ZCAN_USBCAN2
@@ -3,12 +3,7 @@ pub(crate) mod wrappers;
3
3
  use std::sync::{Arc, Mutex};
4
4
  use pyo3::{exceptions, prelude::*};
5
5
  use rs_can::{CanError, CanFrame, CanType, ChannelConfig, DeviceBuilder};
6
- use zlgcan_rs::{
7
- can::{CanMessage, ZCanFrameType},
8
- device::DeriveInfo,
9
- driver::{ZCanDriver, ZDevice},
10
- ACC_CODE, ACC_MASK, BRP, CHANNEL_MODE, CHANNEL_TYPE, DERIVE_INFO, DEVICE_INDEX, DEVICE_TYPE, FILTER_TYPE
11
- };
6
+ use zlgcan_rs::{can::{CanMessage, ZCanFrameType}, device::DeriveInfo, driver::{ZCanDriver, ZDevice}, ACC_CODE, ACC_MASK, BRP, CHANNEL_MODE, CHANNEL_TYPE, DERIVE_INFO, DEVICE_INDEX, DEVICE_TYPE, FILTER_TYPE, LIBPATH};
12
7
  use crate::wrappers::{ZCanChlCfgPy, ZCanDriverWrap, ZCanMessagePy, ZDeriveInfoPy};
13
8
 
14
9
  #[pyfunction]
@@ -24,13 +19,16 @@ fn convert_from_python<'py>(py: Python<'py>, py_message: &Bound<'py, PyAny>) ->
24
19
 
25
20
  #[pyfunction]
26
21
  fn zlgcan_init_can(
22
+ libpath: String,
27
23
  dev_type: u32,
28
24
  dev_idx: u32,
29
25
  cfgs: Vec<ZCanChlCfgPy>,
30
26
  derive_info: Option<ZDeriveInfoPy>,
31
27
  ) -> PyResult<ZCanDriverWrap> {
32
28
  let mut builder = DeviceBuilder::new();
33
- builder.add_other(DEVICE_TYPE, Box::new(dev_type))
29
+ builder
30
+ .add_other(LIBPATH, Box::new(libpath))
31
+ .add_other(DEVICE_TYPE, Box::new(dev_type))
34
32
  .add_other(DEVICE_INDEX, Box::new(dev_idx));
35
33
  derive_info.map(
36
34
  |info| builder.add_other(DERIVE_INFO, Box::<DeriveInfo>::new(info.into()))
@@ -192,7 +190,7 @@ mod tests {
192
190
  None,
193
191
  );
194
192
 
195
- let device = zlgcan_init_can(dev_type, dev_idx, vec![cfg, ], None)?;
193
+ let device = zlgcan_init_can("../../RustProjects/rust-can/zlgcan/library".into(), dev_type, dev_idx, vec![cfg, ], None)?;
196
194
  let dev_info = zlgcan_device_info(&device)?;
197
195
  println!("{}", dev_info);
198
196
  std::thread::sleep(std::time::Duration::from_secs(1));
@@ -201,8 +199,8 @@ mod tests {
201
199
  let mut flag = false;
202
200
  while start.elapsed().as_secs() < 15 {
203
201
  let msgs = zlgcan_recv(&device, 0, None)?;
204
- println!("{:?}", msgs);
205
202
  if !msgs.is_empty() {
203
+ println!("{:?}", msgs);
206
204
  flag = true;
207
205
  }
208
206
  drop(msgs);
@@ -131,6 +131,7 @@ class ZCanBus(can.BusABC):
131
131
 
132
132
  def __init__(self,
133
133
  channel: Union[int, Sequence[int], str] = None, *,
134
+ libpath: str = "library/",
134
135
  device_type: int,
135
136
  device_index: int = 0,
136
137
  derive: ZDeriveInfoPy = None,
@@ -142,6 +143,7 @@ class ZCanBus(can.BusABC):
142
143
  Constructor
143
144
 
144
145
  :param channel: Not used(from super).
146
+ :param libpath: The library root path.
145
147
  :param device_type: The device type that your device belongs, see `ZCANDeviceType`.
146
148
  :param device_index: The device index.
147
149
  :param derive: The deriver info for specifying the channels and canfd supported if your device is not official.
@@ -180,7 +182,7 @@ class ZCanBus(can.BusABC):
180
182
  cfg_list.append(_cfg)
181
183
  self.channels.append(idx)
182
184
 
183
- self.device = zlgcan_init_can(device_type, device_index, cfg_list, derive)
185
+ self.device = zlgcan_init_can(libpath, device_type, device_index, cfg_list, derive)
184
186
 
185
187
  self.dev_info = zlgcan_device_info(self.device)
186
188
  if self.dev_info is not None:
@@ -235,7 +237,9 @@ class ZCanBus(can.BusABC):
235
237
 
236
238
 
237
239
  if __name__ == '__main__':
238
- with ZCanBus(interface="zlgcan", device_type=ZCANDeviceType.ZCAN_USBCANFD_200U,
240
+ with ZCanBus(interface="zlgcan",
241
+ libpath="../../../RustProjects/rust-can/zlgcan/library",
242
+ device_type=ZCANDeviceType.ZCAN_USBCANFD_200U,
239
243
  configs=[{'bitrate': 500000, 'dbitrate': 1_000_000, 'resistance': 1}]) as bus:
240
244
  # bus.send(can.Message(
241
245
  # arbitration_id=0x7DF,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes