Expand description
§libautomotive
libautomotive
is a comprehensive Rust library for automotive protocol implementations,
following the OSI layer model for clear separation of concerns. It provides support for
various automotive protocols including CAN, CAN-FD, ISO-TP, J1939, UDS, and OBD-II.
§Architecture
The library is organized according to the OSI layer model:
- Physical Layer: CAN and CAN-FD implementations
- Data Link Layer: Raw CAN frame handling
- Network Layer: J1939 protocol implementation
- Transport Layer: ISO-TP (ISO 15765-2) implementation
- Application Layer: UDS (ISO 14229) and OBD-II implementations
§Features
- Complete automotive protocol stack
- Modular and extensible design
- High-performance implementations
- Strong type safety and error handling
- Easy-to-use abstractions
§Example
# Complete usage example (conceptual, not actual code)
use libautomotive::physical::can;
use libautomotive::transport::isotp;
use libautomotive::application::uds;
# 1. Set up physical layer (CAN)
let can_config = can::CustomConfig {
bitrate: 500_000,
sample_point: 0.75
};
let mut can = can::CustomInterface::new(can_config);
can.open();
# 2. Set up transport layer (ISO-TP)
let isotp_config = isotp::CustomConfig {
tx_id: 0x7E0,
rx_id: 0x7E8,
block_size: 8,
st_min: 10
};
let mut isotp = isotp::CustomInterface::new_with_can(isotp_config, can);
isotp.open();
# 3. Set up application layer (UDS)
let uds_config = uds::CustomConfig {
timeout_ms: 1000,
p2_timeout_ms: 5000
};
let mut uds = uds::CustomInterface::new_with_isotp(uds_config, isotp);
uds.open();
# 4. Use UDS services
uds.change_session(uds::SESSION_EXTENDED);
let vin = uds.read_data_by_id(0xF190); // Read Vehicle Identification Number
§Credits and Acknowledgments
This library draws inspiration from and acknowledges the following open-source projects:
- esp32-isotp-ble-bridge - ESP32-IDF based BLE<->ISO-TP bridge
- Open-SAE-J1939 - Open source SAE J1939 implementation
- uds-c - Unified Diagnostic Services (UDS) C library
- obdii - OBD-II diagnostic protocol implementation
- canis-can-sdk - CAN protocol stack implementation
- AgIsoStack++ - Open-source C++ ISOBUS library
- open-LIN-c - Implementation of Local Interconnect Network in C
- doip-library - Diagnostic over IP (DoIP) protocol implementation
These projects have provided valuable insights and reference implementations for various automotive protocols. We are grateful to their authors and contributors for making their work available to the community.
Re-exports§
pub use application::obdii;
pub use application::uds;
pub use network::j1939;
pub use physical::can;
pub use physical::canfd;
pub use transport::isotp;
Modules§
- application
- Application layer protocols including UDS and OBD-II Application layer implementations for automotive protocols.
- data_
link - Data link layer handling raw CAN frames
- error
- Common error types and error handling functionality Error types for the automotive protocol stack.
- network
- Network layer implementing J1939 protocol Network layer implementations for automotive protocols.
- physical
- Physical layer implementations for CAN and CAN-FD Physical layer implementations for automotive protocols.
- transport
- Transport layer implementing ISO-TP (ISO 15765-2) Transport layer implementations for automotive protocols.
- types
- Common types used across the library Common types used throughout the automotive protocol stack.
Constants§
- VERSION
- Current version of the library