4 releases

new 0.1.0-alpha3 Mar 26, 2025
0.1.0-alpha2 Mar 24, 2025
0.1.0-alpha1 Nov 15, 2024
0.1.0-alpha0 Nov 11, 2024

#23 in #uds

Download history 5/week @ 2024-12-08 15/week @ 2025-02-16 2/week @ 2025-03-16 212/week @ 2025-03-23

214 downloads per month

MIT OR GPL-3.0

67KB
1.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.6–1.3MB
~30K SLoC