zlgcan 0.2.1b1__tar.gz → 0.2.3b0__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.
@@ -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=e76db38dd2e6d66f0afa9374e9a9513d984b6be2#e76db38dd2e6d66f0afa9374e9a9513d984b6be2"
213
+ source = "git+https://github.com/jesses2025smith/rust-can.git?branch=py#b47be22c135553b723146de65d7bf6f44da26403"
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=e76db38dd2e6d66f0afa9374e9a9513d984b6be2#e76db38dd2e6d66f0afa9374e9a9513d984b6be2"
348
+ source = "git+https://github.com/jesses2025smith/rust-can.git?branch=py#b47be22c135553b723146de65d7bf6f44da26403"
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.1-beta1"
360
+ version = "0.2.3-beta0"
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.1-beta1"
3
+ version = "0.2.3-beta0"
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", package = "rs-can", rev = "e76db38dd2e6d66f0afa9374e9a9513d984b6be2" }
17
- zlgcan = { git = "https://github.com/jesses2025smith/rust-can.git", package = "zlgcan", rev = "e76db38dd2e6d66f0afa9374e9a9513d984b6be2" }
16
+ rs-can = { git = "https://github.com/jesses2025smith/rust-can.git", package = "rs-can", branch = "py" }
17
+ zlgcan = { git = "https://github.com/jesses2025smith/rust-can.git", package = "zlgcan", branch = "py" }
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.2.1b1
3
+ Version: 0.2.3b0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -37,9 +37,13 @@ fn zlgcan_init_can(
37
37
  );
38
38
 
39
39
  for (i, cfg) in cfgs.into_iter().enumerate() {
40
+ let chl_type = ZCanChlType::try_from(cfg.chl_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(CHANNEL_TYPE, Box::new(cfg.chl_type))
42
- .add_other(CHANNEL_MODE, Box::new(cfg.chl_mode));
45
+ c.add_other(CHANNEL_TYPE, Box::new(chl_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,7 +171,6 @@ fn zlgcan_driver(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
167
171
 
168
172
  #[cfg(test)]
169
173
  mod tests {
170
- use std::time::Instant;
171
174
  use zlgcan::{
172
175
  can::{ZCanChlMode, ZCanChlType},
173
176
  device::ZCanDeviceType,
@@ -181,35 +184,42 @@ mod tests {
181
184
  let dev_type = ZCanDeviceType::ZCAN_USBCANFD_200U as u32;
182
185
  let dev_idx = 0;
183
186
  let cfg = ZCanChlCfgPy::new(
184
- ZCanChlType::CANFD_ISO as u8,
187
+ ZCanChlType::CAN as u8,
185
188
  ZCanChlMode::Normal as u8,
186
189
  500_000,
187
190
  None,
188
- Some(1_000_000),
191
+ None,
192
+ None,
193
+ None,
194
+ None,
195
+ None,
196
+ );
197
+ let cfg2 = ZCanChlCfgPy::new(
198
+ ZCanChlType::CAN as u8,
199
+ ZCanChlMode::Normal as u8,
200
+ 500_000,
201
+ None,
202
+ None,
189
203
  None,
190
204
  None,
191
205
  None,
192
206
  None,
193
207
  );
194
208
 
195
- let device = zlgcan_init_can("../../RustProjects/rust-can/zlgcan/library".into(), dev_type, dev_idx, vec![cfg, ], None)?;
209
+ let device = zlgcan_init_can("../../RustRoverProjects/rust-can/zlgcan/library".into(), dev_type, dev_idx, vec![cfg, cfg2], None)?;
196
210
  let dev_info = zlgcan_device_info(&device)?;
197
211
  println!("{}", dev_info);
198
212
  std::thread::sleep(std::time::Duration::from_secs(1));
199
213
 
200
- let start = Instant::now();
201
- let mut flag = false;
202
- while start.elapsed().as_secs() < 15 {
203
- let msgs = zlgcan_recv(&device, 0, None)?;
204
- if !msgs.is_empty() {
205
- println!("{:?}", msgs);
206
- flag = true;
207
- }
208
- drop(msgs);
209
-
210
- if flag {
211
- break;
212
- }
214
+ let mut msg = CanMessage::new(0x7df, &vec![0x02, 0x10, 0x01]).unwrap();
215
+ msg.set_channel(0);
216
+ let ret = zlgcan_send(&device, msg.into())?;
217
+ println!("send: {}", ret);
218
+
219
+ std::thread::sleep(std::time::Duration::from_micros(200));
220
+ let msgs = zlgcan_recv(&device, 1, None)?;
221
+ if !msgs.is_empty() {
222
+ println!("{:?}", msgs);
213
223
  }
214
224
 
215
225
  zlgcan_close(&device)?;
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