| Crates.io | zlgcan |
| lib.rs | zlgcan |
| version | 0.2.7 |
| created_at | 2024-09-04 06:39:42.864988+00 |
| updated_at | 2025-08-01 09:14:25.658946+00 |
| description | A Cross-platform ZLGCAN driver. |
| homepage | https://github.com/jesses2025smith/rust-can/tree/master/zlgcan |
| repository | https://github.com/jesses2025smith/rust-can |
| max_upload_size | |
| id | 1362900 |
| size | 292,846 |
zlgcan is a cross-platform driver for ZLG(周立功) device. Include windows and linux.
It is a part of rust-can driver.
It also can use UDS-protocol directly.
Please refer to examples for usage examples
use rs_can::{CanError, DeviceBuilder, ChannelConfig};
use zlgcan_rs::{can::{ZCanChlMode, ZCanChlType}, device::ZCanDeviceType, driver::{ZDevice, ZDriver}, CHANNEL_MODE, CHANNEL_TYPE, DEVICE_INDEX, DEVICE_TYPE, LIBPATH};
fn main() -> Result<(), CanError> {
let mut builder = DeviceBuilder::new();
let mut ch1_cfg = ChannelConfig::new(500_000);
ch1_cfg.add_other(CHANNEL_MODE, Box::new(ZCanChlMode::Normal))
.add_other(CHANNEL_TYPE, Box::new(ZCanChlType::CAN));
let mut ch2_cfg = ChannelConfig::new(500_000);
ch2_cfg.add_other(CHANNEL_MODE, Box::new(ZCanChlMode::Normal))
.add_other(CHANNEL_TYPE, Box::new(ZCanChlType::CAN));
builder
.add_other(LIBPATH, Box::new("library".to_string()))
.add_other(DEVICE_TYPE, Box::new(ZCanDeviceType::ZCAN_USBCANFD_200U))
.add_other(DEVICE_INDEX, Box::new(0))
.add_config(0, ch1_cfg)
.add_config(1, ch2_cfg);
let device = builder.build::<ZDriver>()?;
// todo something
Ok(())
}
To use zlgcan in your Rust project, add it as a dependency in your Cargo.toml:
[dependencies]
zlgcan = { version="lastest-version" }
Create folder and ensure the file of folder like:
library
├── bitrate.cfg.yaml
├── linux
│ └── x86_64
└── windows
├── x86
└── x86_64
and copy all files into correct directory.
The basic library. The bitrate.cfg.yaml
Configurate your device builder:
fn main() {
let mut builder = DeviceBuilder::new();
builder
.add_other(LIBPATH, Box::new("library".to_string()))
}
We're always looking for users who have thoughts on how to make zlgcan better, or users with
interesting use cases.
Of course, we're also happy to accept code contributions for outstanding feature requests!