can-hal-rs defines the interface. Backend crates implement it. Application code is portable across CAN hardware.
no_std support
This crate is no_std-compatible (requires Rust 1.81+). The std feature is enabled by default. To use in embedded / no_std contexts:
[]
= { = "0.3", = false }
Traits
| Trait | Purpose |
|---|---|
Transmit / Receive |
Classic CAN (up to 8 bytes) |
TransmitFd / ReceiveFd |
CAN FD (up to 64 bytes) |
Driver / ChannelBuilder |
Open and configure channels |
Filterable |
Hardware acceptance filtering |
BusStatus |
Bus state and error counters |
Async variants (AsyncTransmit, AsyncReceive, etc.) are available behind the async feature flag.
Usage
use ;
Backend crates
can-hal-socketcan— Linux SocketCANcan-hal-pcan— PEAK PCAN-Basic (Windows and Linux)can-hal-kvaser— KVASER CANlib (Windows and Linux)
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.