3 releases

new 0.1.2 Mar 8, 2025
0.1.1 Feb 23, 2025
0.1.0 Feb 23, 2025

#158 in Embedded development

Download history 118/week @ 2025-02-17 120/week @ 2025-02-24 110/week @ 2025-03-03

348 downloads per month

MIT license

165KB
4K SLoC

libautomotive

A comprehensive Rust library for automotive protocol implementations, following the OSI layer model for clear separation of concerns. The library provides support for various automotive protocols including CAN, CAN-FD, ISO-TP, J1939, ISOBUS, UDS, and OBD-II.

Features

  • Complete automotive protocol stack implementation
  • Modular and extensible design following OSI layers
  • High-performance implementations
  • Strong type safety and error handling
  • Easy-to-use abstractions

Supported Protocols

  • Physical Layer: CAN and CAN-FD implementations
  • Data Link Layer: Raw CAN frame handling
  • Network Layer: J1939 and ISOBUS protocol implementations
  • Transport Layer: ISO-TP (ISO 15765-2) implementation
  • Application Layer:
    • UDS (ISO 14229) implementation
    • OBD-II implementation
    • ISOBUS Diagnostic Protocol (DM1, DM2, DM3, DM11, DM13, DM22)

Building

  1. Ensure you have Rust and Cargo installed (https://rustup.rs/)
  2. Clone the repository:
    git clone https://github.com/shishir-dey/libautomotive.git
    cd libautomotive
    
  3. Build the library:
    cargo build
    
  4. For release build:
    cargo build --release
    

Testing

Run the test suite:

cargo test

For verbose test output:

cargo test -- --nocapture

Example Usage

use libautomotive::application::{uds, obdii};
use libautomotive::transport::isobus_diagnostic;

// UDS example
let uds_config = uds::Config::default();
let uds_interface = uds::Interface::new(uds_config);

// OBD-II example
let obd_config = obdii::Config::default();
let obd_interface = obdii::Interface::new(obd_config);

// ISOBUS Diagnostic example
let mut isobus_diag = isobus_diagnostic::ISOBUSDiagnosticProtocol::new();
let dtc = isobus_diagnostic::DiagnosticTroubleCode::new(100, 1); // SPN: 100, FMI: 1
isobus_diag.add_dtc(dtc);

License

MIT

Credits and Acknowledgments

This library draws inspiration from and acknowledges the following open-source projects:

Dependencies

~110KB