A Rust library for Linux SocketCAN communication, providing network socket access to CAN bus with async support.
socketcan-rs is a Rust library that provides access to Linux's SocketCAN subsystem, enabling CAN bus communication through network sockets. It solves the problem of interacting with CAN devices from Rust applications on Linux, offering both synchronous and asynchronous APIs. The library supports standard CAN and CAN FD frames, interface configuration via Netlink, and integration with popular async runtimes.
Rust developers working on Linux systems who need to communicate with CAN buses in embedded systems, automotive applications, or industrial automation. It's also suitable for those building tools for CAN network analysis or simulation.
Developers choose socketcan-rs because it provides a native, idiomatic Rust API for SocketCAN with optional async support for multiple runtimes, eliminating the need for C bindings or separate crates. Its comprehensive feature set, including CAN FD and Netlink control, makes it a one-stop solution for CAN communication in Rust.
Linux SocketCAN access in Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Optional integration with multiple runtimes (Tokio, async-std, smol) via feature flags, enabling non-blocking CAN operations for high-performance applications, as shown in the example bridge code.
Supports CAN FD with proper frame padding and DLC management, plus dedicated types like CanDataFrame and CanRemoteFrame for robust frame handling.
Allows full control over CAN interfaces via Netlink, enabling bitrate setting, mode control, and parameter querying directly from Rust, as enhanced in versions 3.1 and 3.2.
Implements embedded_hal traits for CanFdSocket, making it compatible with embedded Rust projects and easing integration into hardware-focused applications.
Tied exclusively to Linux's SocketCAN subsystem, making it unsuitable for projects on other operating systems and limiting portability.
Requires root access and manual setup of virtual CAN devices (e.g., vcan0) for testing, which complicates CI/CD pipelines and development workflows.
Hardware timestamps are not yet implemented, as noted in issue #22, which can be a drawback for time-sensitive applications like real-time diagnostics.