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§
- Extended
Id - Extended 29-bit CAN Identifier (
0..=1FFF_FFFF
). - Flow
Control Options - Flow control options aka
can_isotp_fc_options
- IsoTp
Behaviour - IsoTp
Options - ISO-TP otions aka
can_isotp_options
- IsoTp
Socket - An ISO-TP socketcan socket.
- Link
Layer Options - Link layer options aka
can_isotp_ll_options
- Standard
Id - Standard 11-bit CAN Identifier (
0..=0x7FF
). - TxFlags
Enums§
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