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§

ExtendedId
Extended 29-bit CAN Identifier (0..=1FFF_FFFF).
FlowControlOptions
Flow control options aka can_isotp_fc_options
IsoTpBehaviour
IsoTpOptions
ISO-TP otions aka can_isotp_options
IsoTpSocket
An ISO-TP socketcan socket.
LinkLayerOptions
Link layer options aka can_isotp_ll_options
StandardId
Standard 11-bit CAN Identifier (0..=0x7FF).
TxFlags

Enums§

Error
Possible errors
Id
A CAN Identifier (standard or extended).

Constants§

AF_CAN
CAN address family
CAN_ISOTP
ISO 15765-2 Transport Protocol
CAN_ISOTP_LL_OPTS
pass struct LinkLayerOptions
CAN_ISOTP_OPTS
pass struct IsoTpOptions
CAN_ISOTP_RECV_FC
pass struct FlowControlOptions
CAN_ISOTP_RX_STMIN
pass __u32 value in nano secs ignore received CF frames which timestamps differ less than val
CAN_ISOTP_TX_STMIN
pass __u32 value in nano secs use this time instead of value provided in FC from the receiver
CAN_MAX_DLEN
CAN_MAX_DLEN According to ISO 11898-1
EFF_FLAG
if set, indicate 29 bit extended format
EFF_MASK
valid bits in extended frame id
ERR_FLAG
error flag
ERR_MASK
valid bits in error frame
ERR_MASK_ALL
an error mask that will cause Socketcan to report all errors
ERR_MASK_NONE
an error mask that will cause Socketcan to silently drop all errors
PF_CAN
CAN protocol family
RTR_FLAG
remote transmission request flag
SFF_MASK
valid bits in standard frame id
SOL_CAN_BASE
undocumented can.h constant
SOL_CAN_ISOTP
undocumented isotp.h constant