Welcome to the automotive
crate documentation. The purpose of this crate is to help you with all things automotive related. Most importantly, it provides a fully async CAN interface supporting multiple adapters.
The following adapter opens the first available adapter on the system, and then receives all frames.
let adapter = automotive::adapter::get_adapter().unwrap();
let mut stream = adapter.recv();
while let Some(frame) = stream.next().await {
let id: u32 = frame.id.into();
println!("[{}]\t0x{:x}\t{}", frame.bus, id, hex::encode(frame.data));
}
The automotive crate also supplies interfaces for various diagnostic protocols such as UDS. The adapter is first wrapped to support the ISO Transport Layer, then a UDS Client is created. All methods are fully async, making it easy to communicate with multiple ECUs in parallel. See #21 for progress on the supported SIDs.
let adapter = automotive::adapter::get_adapter().unwrap();
let isotp = automotive::isotp::IsoTPAdapter::from_id(&adapter, 0x7a1);
let uds = automotive::uds::UDSClient::new(&isotp);
uds.tester_present().await.unwrap();
let response = uds.read_data_by_identifier(DataIdentifier::ApplicationSoftwareIdentification as u16).await.unwrap();
println!("Application Software Identification: {}", hex::encode(response));
The following adapters are supported. Hardware implementations can be blocking, as the AsyncCanAdapter takes care of presenting an async interface to the user.
- SocketCAN (Linux only, supported using socketcan-rs)
- comma.ai panda (all platforms)
Features I'd like to add in the future. Also check the issues page.
- CCP/XCP Client
- Update file extraction (e.g. .frf and .odx)
- VIN Decoding
- J2534 Support on Windows
- More raw device support, such as ValueCAN and P-CAN by reverse engineering the USB protocol
- WebUSB support