j2534

Crates.ioj2534
lib.rsj2534
version0.3.1
sourcesrc
created_at2018-11-05 14:10:02.065382
updated_at2020-12-27 18:03:30.098707
descriptionPassThru (SAE J2534) bindings.
homepage
repositoryhttps://github.com/altenius/j2534-rs
max_upload_size
id94844
size53,455
Jacob (jcmnn)

documentation

https://docs.rs/j2534

README

J2534

Low-level SAE J2534 (PassThru) support for rust.

J2534 Introduction

SAE J2534 PassThru defines a standard library interface for communicating with vehicle control modules. All automakers in the US are required to provide J2534-compatible service software. J2534 provides access to the communication layer required for accessing vehicle diagnostics services as well as downloading and reflashing control modules.

Usage

The J2534 specification requires PassThru libraries to be compiled for 32 bit, so any program using this crate must be compiled as 32 bit.

Example

use j2534::{Interface, PassThruMsg, Protocol, ConnectFlags, RxStatus, TxFlags};

fn main() -> j2534::Result<()> {
    // Open the library and connect to a device
    let interface = Interface::new("C:\\device.dll")?;
    let device = interface.open_any()?;
    
    // Create a CAN channel
    let channel = device
        .connect(Protocol::CAN, ConnectFlags::NONE, 500000)
        .unwrap();
    // Create a new message with an arbitration id of `8` and payload of `[0, 1, 2, 3]`.
    let message = PassThruMsg::new_can(8, &[0, 1, 2, 3]);
    channel.write(&mut [message], 1000)?;
    Ok(())
}
Commit count: 51

cargo fmt