An open API service indexing awesome lists of open source software.

https://github.com/nyurik/automotive_diag

Unified Diagnostic Services/UDS (ISO-14229-1), KWP2000 (ISO-142330) and OBD-II (ISO-9141) definitions to communicate with the road vehicle ECUs in Rust.
https://github.com/nyurik/automotive_diag

Last synced: 25 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# Automotive diagnostics in Rust

[![GitHub](https://img.shields.io/badge/github-nyurik/automotive_diag-8da0cb?logo=github)](https://github.com/nyurik/automotive_diag)
[![crates.io version](https://img.shields.io/crates/v/automotive_diag)](https://crates.io/crates/automotive_diag)
[![docs.rs](https://img.shields.io/docsrs/automotive_diag)](https://docs.rs/automotive_diag)
[![crates.io license](https://img.shields.io/crates/l/automotive_diag)](https://github.com/nyurik/automotive_diag/blob/main/LICENSE-APACHE)
[![CI build](https://github.com/nyurik/automotive_diag/actions/workflows/ci.yml/badge.svg)](https://github.com/nyurik/automotive_diag/actions)
[![Codecov](https://img.shields.io/codecov/c/github/nyurik/automotive_diag)](https://app.codecov.io/gh/nyurik/automotive_diag)

This crate provides low-level `no_std` structs and enums of
the [Unified Diagnostic Services](https://en.wikipedia.org/wiki/Unified_Diagnostic_Services) (ISO-14229-1),
[KWP2000](https://en.wikipedia.org/wiki/Keyword_Protocol_2000) (ISO-142330) and
[OBD-II](https://en.wikipedia.org/wiki/On-board_diagnostics) (ISO-9141)
specifications for the road vehicles in Rust.

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

## 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` to
handle the non-standard `Extended(u8)` values in addition to the defined `Standand(T)` ones.

```rust
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](https://github.com/casey/just#readme), 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](https://github.com/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](https://crates.io/crates/auto_uds) crate.

## License

Licensed under either of

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license ([LICENSE-MIT](LICENSE-MIT) or )
at your option.

### 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.