Crates.io | canopeners |
lib.rs | canopeners |
version | 0.2.0 |
source | src |
created_at | 2024-01-17 20:49:18.37592 |
updated_at | 2024-01-17 20:51:43.191475 |
description | CANOpen client library |
homepage | |
repository | |
max_upload_size | |
id | 1103395 |
size | 57,952 |
Incomplete, but easy to use implementation of the CANOpen standard in Rust.
All examples are blocking. Set timeouts with conn.set_{read_write}_timeout
.
Send a single message:
Conn::new("vcan0").map(|conn| {
let nmt = Nmt::new(canopeners::NmtFunction::StartRemoteNode, 10);
conn.send(&Message::Nmt(nmt)).unwrap();
})
Write bytes to object dictionary on a remote node:
Conn::new("vcan0").map(|mut conn| {
conn.sdo_write(
/* remote node id */ 0x10,
/* index */ 0x1000,
/* sub index */ 1,
/* data, can be any length */ &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
.unwrap();
})
Read bytes from object dictionary on a remote node:
Conn::new("vcan0").map(|mut conn| {
let res = conn.sdo_read(
/* remote node id */ 0x10,
/* index */ 0x1000,
/* sub index */ 1)
.unwrap();
dbg!(res);
})
nix develop
cargo build
if you'd rather use your system cargo, just cargo build
will work too
setup_vcan.sh
sets up a virtual CAN bus. tests/
rely on this
send_acked
for all message types