#automotive-ecu #automotive #uds #no-std #obd #environment #kwp2000

no-std automotive_diag

Unified Diagnostic Services/UDS (ISO-14229-1), KWP2000 (ISO-142330), OBD-II (ISO-9141), and DoIP (ISO-13400) definitions to communicate with the road vehicle ECUs in Rust

19 releases

new 0.1.18 Jun 6, 2025
0.1.12 Apr 9, 2025
0.1.11 Feb 11, 2025
0.1.9 Jul 24, 2024
0.1.4 May 21, 2023

#69 in Embedded development

Download history 1588/week @ 2025-02-15 1124/week @ 2025-02-22 1208/week @ 2025-03-01 1889/week @ 2025-03-08 1474/week @ 2025-03-15 1409/week @ 2025-03-22 1213/week @ 2025-03-29 1507/week @ 2025-04-05 1693/week @ 2025-04-12 2288/week @ 2025-04-19 1473/week @ 2025-04-26 2037/week @ 2025-05-03 1326/week @ 2025-05-10 1353/week @ 2025-05-17 1705/week @ 2025-05-24 1276/week @ 2025-05-31

5,937 downloads per month
Used in 2 crates

MIT/Apache

105KB
1.5K SLoC

Automotive diagnostics in Rust

GitHub repo crates.io version docs.rs status crates.io license CI build status Codecov

This crate provides low-level no_std structs and enums of the Unified Diagnostic Services (ISO-14229-1), KWP2000 (ISO-142330), OBD-II (ISO-9141) and DoIP (ISO-13400) diagnostic specifications for the road vehicles in Rust. Optionally supports defmt, serde, and pyo3. See features section in the Cargo.toml file.

Most features have been implemented and documented to handle the most common diagnostic commands and responses. If you find a missing feature, please open an issue or better yet, a pull request.

The long-term goal is to provide all core functionality for message definitions and (de-)serialization, supporting both the no_std and std environments.

Usage

All values are presented as Rust enum, and can be converted to/from their underlying numeric values using the T::from_repr(u8) and u8::from(value). Most enums also have a corresponding ...Byte enums as ByteWrapper<T> to handle the non-standard Extended(u8) values in addition to the defined Standand(T) ones.

use automotive_diag::ByteWrapper::{Extended, Standard};
use automotive_diag::uds::UdsCommand::{DiagnosticSessionControl, ECUReset};
use automotive_diag::uds::UdsCommandByte;

/// Handle a single command byte on the ECU side
fn handle_cmd_byte(cmd: u8) {
    match UdsCommandByte::from(cmd) {
        Standard(DiagnosticSessionControl) => {
            // handle_diag_session()
        }
        Standard(ECUReset) => {
            // handle_ecu_reset()
        }
        Extended(0x42) => {
            // handle_custom_cmd_42()
        }
        _ => {
            // handle all other commands
        }
    }
}

Development

  • This project is easier to develop with just, a modern alternative to make. Install it with cargo install just.
  • To get a list of available commands, run just.
  • To run tests, use just test.

Credits

The code was forked from the amazing rnd-ash/ecu_diagnostics project. The code was forked from the last MIT-versioned code before the MIT to GPL license migration. Initially, this code was developed as a deprecated auto_uds crate. The DoIP definitions were adapted from the MIT-licensed samp-reston/doip-definitions project.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

Dependencies

~0.2–1.5MB
~32K SLoC

OSZAR »