zlgcan 0.2.1b1__tar.gz → 0.2.2__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.
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/Cargo.lock +3 -3
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/Cargo.toml +3 -3
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/PKG-INFO +1 -1
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/src/lib.rs +30 -23
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/src/wrappers/mod.rs +5 -5
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/zlgcan/zlgcan.py +5 -6
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/.editorconfig +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/.github/workflows/CI.yml +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/.github/workflows/label-check.yml +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/.gitignore +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/CHANGELOG.md +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/LICENSE.txt +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/README.md +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/pyproject.toml +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/requirements.txt +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/src/wrappers/constants.rs +0 -0
- {zlgcan-0.2.1b1 → zlgcan-0.2.2}/zlgcan/__init__.py +0 -0
@@ -210,7 +210,7 @@ dependencies = [
|
|
210
210
|
[[package]]
|
211
211
|
name = "rs-can"
|
212
212
|
version = "0.3.0"
|
213
|
-
source = "git+https://github.com/jesses2025smith/rust-can.git?rev=
|
213
|
+
source = "git+https://github.com/jesses2025smith/rust-can.git?rev=05a051f662385bcc33cd99bf195eedaa528983fe#05a051f662385bcc33cd99bf195eedaa528983fe"
|
214
214
|
dependencies = [
|
215
215
|
"bitflags",
|
216
216
|
"derive-getters",
|
@@ -345,7 +345,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
345
345
|
[[package]]
|
346
346
|
name = "zlgcan"
|
347
347
|
version = "0.3.0"
|
348
|
-
source = "git+https://github.com/jesses2025smith/rust-can.git?rev=
|
348
|
+
source = "git+https://github.com/jesses2025smith/rust-can.git?rev=05a051f662385bcc33cd99bf195eedaa528983fe#05a051f662385bcc33cd99bf195eedaa528983fe"
|
349
349
|
dependencies = [
|
350
350
|
"dlopen2",
|
351
351
|
"log",
|
@@ -357,7 +357,7 @@ dependencies = [
|
|
357
357
|
|
358
358
|
[[package]]
|
359
359
|
name = "zlgcan-driver"
|
360
|
-
version = "0.2.
|
360
|
+
version = "0.2.2"
|
361
361
|
dependencies = [
|
362
362
|
"anyhow",
|
363
363
|
"pyo3",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[package]
|
2
2
|
name = "zlgcan-driver"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.2"
|
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.25"
|
|
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 = { git = "https://github.com/jesses2025smith/rust-can.git",
|
17
|
-
zlgcan = { git = "https://github.com/jesses2025smith/rust-can.git",
|
16
|
+
rs-can = { git = "https://github.com/jesses2025smith/rust-can.git", rev = "05a051f662385bcc33cd99bf195eedaa528983fe", package = "rs-can" }
|
17
|
+
zlgcan = { git = "https://github.com/jesses2025smith/rust-can.git", rev = "05a051f662385bcc33cd99bf195eedaa528983fe", package = "zlgcan" }
|
18
18
|
|
19
19
|
[dev-dependencies]
|
20
20
|
anyhow = "1"
|
@@ -37,9 +37,13 @@ fn zlgcan_init_can(
|
|
37
37
|
);
|
38
38
|
|
39
39
|
for (i, cfg) in cfgs.into_iter().enumerate() {
|
40
|
+
let fdchl_type = ZCanFdChlType::try_from(cfg.fdchl_type)
|
41
|
+
.map_err(|e| exceptions::PyValueError::new_err(e.to_string()))?;
|
42
|
+
let chl_mode = ZCanChlMode::try_from(cfg.chl_mode)
|
43
|
+
.map_err(|e| exceptions::PyValueError::new_err(e.to_string()))?;
|
40
44
|
let mut c = ChannelConfig::new(cfg.bitrate);
|
41
|
-
c.add_other(
|
42
|
-
.add_other(CHANNEL_MODE, Box::new(
|
45
|
+
c.add_other(FD_CHANNEL_TYPE, Box::new(fdchl_type))
|
46
|
+
.add_other(CHANNEL_MODE, Box::new(chl_mode));
|
43
47
|
|
44
48
|
cfg.dbitrate.map(|dbitrate| c.set_data_bitrate(dbitrate));
|
45
49
|
cfg.resistance.map(|resistance| c.set_resistance(resistance));
|
@@ -167,11 +171,7 @@ fn zlgcan_driver(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
167
171
|
|
168
172
|
#[cfg(test)]
|
169
173
|
mod tests {
|
170
|
-
use
|
171
|
-
use zlgcan::{
|
172
|
-
can::{ZCanChlMode, ZCanChlType},
|
173
|
-
device::ZCanDeviceType,
|
174
|
-
};
|
174
|
+
use zlgcan::{can::ZCanChlMode, device::ZCanDeviceType};
|
175
175
|
use super::*;
|
176
176
|
|
177
177
|
#[test]
|
@@ -181,35 +181,42 @@ mod tests {
|
|
181
181
|
let dev_type = ZCanDeviceType::ZCAN_USBCANFD_200U as u32;
|
182
182
|
let dev_idx = 0;
|
183
183
|
let cfg = ZCanChlCfgPy::new(
|
184
|
-
ZCanChlType::CANFD_ISO as u8,
|
185
184
|
ZCanChlMode::Normal as u8,
|
186
185
|
500_000,
|
187
186
|
None,
|
188
|
-
|
187
|
+
None,
|
188
|
+
Some(true),
|
189
|
+
None,
|
190
|
+
None,
|
191
|
+
None,
|
192
|
+
None,
|
193
|
+
);
|
194
|
+
let cfg2 = ZCanChlCfgPy::new(
|
195
|
+
ZCanChlMode::Normal as u8,
|
196
|
+
500_000,
|
197
|
+
None,
|
198
|
+
None,
|
199
|
+
Some(true),
|
189
200
|
None,
|
190
201
|
None,
|
191
202
|
None,
|
192
203
|
None,
|
193
204
|
);
|
194
205
|
|
195
|
-
let device = zlgcan_init_can("../../
|
206
|
+
let device = zlgcan_init_can("../../RustRoverProjects/rust-can/zlgcan/library".into(), dev_type, dev_idx, vec![cfg, cfg2], None)?;
|
196
207
|
let dev_info = zlgcan_device_info(&device)?;
|
197
208
|
println!("{}", dev_info);
|
198
209
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
199
210
|
|
200
|
-
let
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
if flag {
|
211
|
-
break;
|
212
|
-
}
|
211
|
+
let mut msg = CanMessage::new(0x7df, &vec![0x02, 0x10, 0x01]).unwrap();
|
212
|
+
msg.set_channel(0);
|
213
|
+
let ret = zlgcan_send(&device, msg.into())?;
|
214
|
+
println!("send: {}", ret);
|
215
|
+
|
216
|
+
std::thread::sleep(std::time::Duration::from_micros(200));
|
217
|
+
let msgs = zlgcan_recv(&device, 1, None)?;
|
218
|
+
if !msgs.is_empty() {
|
219
|
+
println!("{:?}", msgs);
|
213
220
|
}
|
214
221
|
|
215
222
|
zlgcan_close(&device)?;
|
@@ -38,14 +38,14 @@ pub struct ZCanDriverWrap {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
#[pyclass]
|
41
|
-
#[derive(Clone)]
|
41
|
+
#[derive(Debug, Clone)]
|
42
42
|
pub struct ZCanChlCfgPy {
|
43
|
-
pub(crate) chl_type: u8,
|
44
43
|
pub(crate) chl_mode: u8,
|
45
44
|
pub(crate) bitrate: u32,
|
46
45
|
pub(crate) filter: Option<u8>,
|
47
46
|
pub(crate) dbitrate: Option<u32>,
|
48
47
|
pub(crate) resistance: Option<bool>,
|
48
|
+
pub(crate) fdchl_type: u8,
|
49
49
|
pub(crate) acc_code: Option<u32>,
|
50
50
|
pub(crate) acc_mask: Option<u32>,
|
51
51
|
pub(crate) brp: Option<u32>,
|
@@ -54,25 +54,25 @@ pub struct ZCanChlCfgPy {
|
|
54
54
|
#[pymethods]
|
55
55
|
impl ZCanChlCfgPy {
|
56
56
|
#[new]
|
57
|
-
#[pyo3(signature = (
|
57
|
+
#[pyo3(signature = (chl_mode, bitrate, filter=None, dbitrate=None, resistance=None, fdchl_type=None, acc_code=None, acc_mask=None, brp=None))]
|
58
58
|
pub fn new(
|
59
|
-
chl_type: u8,
|
60
59
|
chl_mode: u8,
|
61
60
|
bitrate: u32,
|
62
61
|
filter: Option<u8>,
|
63
62
|
dbitrate: Option<u32>,
|
64
63
|
resistance: Option<bool>,
|
64
|
+
fdchl_type: Option<u8>,
|
65
65
|
acc_code: Option<u32>,
|
66
66
|
acc_mask: Option<u32>,
|
67
67
|
brp: Option<u32>,
|
68
68
|
) -> Self {
|
69
69
|
ZCanChlCfgPy {
|
70
|
-
chl_type,
|
71
70
|
chl_mode,
|
72
71
|
bitrate,
|
73
72
|
filter,
|
74
73
|
dbitrate,
|
75
74
|
resistance,
|
75
|
+
fdchl_type: fdchl_type.unwrap_or(0),
|
76
76
|
acc_code,
|
77
77
|
acc_mask,
|
78
78
|
brp,
|
@@ -28,10 +28,9 @@ except ModuleNotFoundError:
|
|
28
28
|
}.get(_platform, not_support)
|
29
29
|
|
30
30
|
|
31
|
-
class
|
32
|
-
|
33
|
-
|
34
|
-
CANFD_NON_ISO = 2
|
31
|
+
class ZCanFdChlType:
|
32
|
+
ISO = 0
|
33
|
+
NON_ISO = 1
|
35
34
|
|
36
35
|
class ZCanChlMode:
|
37
36
|
Normal = 0
|
@@ -169,12 +168,12 @@ class ZCanBus(can.BusABC):
|
|
169
168
|
dbitrate = cfg.get("dbitrate", None)
|
170
169
|
assert bitrate is not None, "bitrate is required!"
|
171
170
|
_cfg = ZCanChlCfgPy(
|
172
|
-
|
173
|
-
chl_mode=cfg.get("chl_mode", 0),
|
171
|
+
chl_mode=cfg.get("chl_mode", ZCanChlMode.Normal),
|
174
172
|
bitrate=bitrate,
|
175
173
|
filter=cfg.get("filter"),
|
176
174
|
dbitrate=dbitrate,
|
177
175
|
resistance=bool(cfg.get("resistance", 1)),
|
176
|
+
fdchl_type=cfg.get("fdchl_type", ZCanFdChlType.ISO),
|
178
177
|
acc_code=cfg.get("acc_code"),
|
179
178
|
acc_mask=cfg.get("acc_mask"),
|
180
179
|
brp=cfg.get("brp")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|