2 releases

new 0.1.0-alpha1 Nov 15, 2024
0.1.0-alpha0 Nov 11, 2024

#3 in #ecu

Download history 213/week @ 2024-11-10

213 downloads per month

MIT OR GPL-3.0

230KB
5K SLoC

DoCAN Protocol

Latest version Documentation LGPL MIT

Overview

Diagnostic Communication over Controller Area Network (DoCAN) is a specialized protocol used primarily in automotive and industrial settings.

The driver must implement the CanDriver trait defined in rs-can.

The Server example
fn main() -> anyhow::Result<()> {
    let driver = YourDriver;
    let mut adapter = IsoTpAdapter::new(driver);

    let mut server = DoCanServer::new(adapter.clone(), CHANNEL, Address {
        tx_id: 0x7E8,
        rx_id: 0x7E0,
        fid: 0x7DF,
    });

    adapter.start(100);

    let msg = YourFrame;
    server.adapter().sender().send(msg)?;

    server.service_forever(100)?;
    
    server.service_stop()?;
    
    Ok(())
}

The client example

fn main() -> anyhow::Result<()> {
    let driver = YourDriver;
    let mut adapter = IsoTpAdapter::new(driver);

    let mut client = DoCanClient::new(adapter.clone(), None);
    client.init_channel(CHANNEL, Address {
        tx_id: 0x7E0,
        rx_id: 0x7E8,
        fid: 0x7DF,
    })?;

    adapter.start(100);

    let msg = YourFrame;
    client.adapter().sender().send(msg)?;
    
    client.session_ctrl(CHANNEL, SessionType::Default, true, AddressType::Functional)?;
    client.session_ctrl(CHANNEL, SessionType::Extended, false, AddressType::Physical)?;
    
    Ok(())
}

Prerequisites

  • Rust 1.70 or higher
  • Cargo (included with Rust)

Contributing

We're always looking for users who have thoughts on how to make docan better, or users with interesting use cases. Of course, we're also happy to accept code contributions for outstanding feature requests!

Dependencies

~0.4–7MB
~42K SLoC