Crate socketcan_isotp

source ·
Expand description

Socketcan ISO-TP support.

The Linux kernel supports using CAN-devices through a network-like API. This crate allows easy access to this functionality without having to wrestle libc calls.

ISO-TP allows sending data packets that exceed the eight byte of a default CAN frame. can-isotp is an ISO-TP kernel module that takes care of handling the ISO-TP protocol.

Instructions on how the can-isotp kernel module can be build and loaded can be found at https://github.com/hartkopp/can-isotp .

use socketcan_isotp::IsoTpSocket;

fn main() -> Result<(), socketcan_isotp::Error> {
    let mut tp_socket = IsoTpSocket::open(
        "vcan0",
        0x123,
        0x321
    )?;

    loop {
        let buffer = tp_socket.read()?;
        println!("read {} bytes", buffer.len());

        // print TP frame data
        for x in buffer {
            print!("{:X?} ", x);
        }

        println!("");
    }

    Ok(())
}

Structs

Enums

  • Possible errors
  • A CAN Identifier (standard or extended).

Constants