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

no-std automotive_diag

Core definitions for various Automotive ECU Diagnostics such as UDS ISO-14229, KWP2000, OBD-II, etc

7 releases

0.1.6 Nov 8, 2023
0.1.5 Aug 31, 2023
0.1.4 May 21, 2023
0.1.3 Apr 15, 2023

#3 in #uds

Download history 89/week @ 2024-01-10 265/week @ 2024-01-17 181/week @ 2024-01-24 173/week @ 2024-01-31 35/week @ 2024-02-07 216/week @ 2024-02-14 356/week @ 2024-02-21 255/week @ 2024-02-28 459/week @ 2024-03-06 440/week @ 2024-03-13 552/week @ 2024-03-20 840/week @ 2024-03-27 387/week @ 2024-04-03 734/week @ 2024-04-10 1204/week @ 2024-04-17 736/week @ 2024-04-24

3,400 downloads per month
Used in ecu_diagnostics

MIT/Apache

63KB
1K SLoC

automotive_diag

GitHub crates.io version docs.rs docs crates.io version CI build

This crate provides low-level no_std structs and enums of the Unified Diagnostic Services (ISO-14229-1), KWP2000 (ISO-142330) and OBD-II (ISO-9141) specifications for the road vehicles in Rust.

Usage

All values are presented as Rust enum, and can be converted to/from their underlying numeric values using the From<T> and TryFrom<u8> traits. 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.
  • On git push, it will run a few validations, including cargo fmt, cargo clippy, and cargo test. Use git push --no-verify to skip these checks.

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.

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

~1.5MB
~33K SLoC