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.
- Host: GitHub
- URL: https://github.com/nyurik/automotive_diag
- Owner: nyurik
- License: apache-2.0
- Created: 2023-03-13T02:07:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T15:48:23.000Z (about 1 month ago)
- Last Synced: 2025-03-29T10:09:18.143Z (about 1 month ago)
- Language: Rust
- Homepage:
- Size: 112 KB
- Stars: 42
- Watchers: 6
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Automotive diagnostics in Rust
[](https://github.com/nyurik/automotive_diag)
[](https://crates.io/crates/automotive_diag)
[](https://docs.rs/automotive_diag)
[](https://github.com/nyurik/automotive_diag/blob/main/LICENSE-APACHE)
[](https://github.com/nyurik/automotive_diag/actions)
[](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.