Crates.io | socketcan-isotp |
lib.rs | socketcan-isotp |
version | 1.0.2 |
source | src |
created_at | 2019-12-10 14:09:57.526581 |
updated_at | 2023-06-28 21:11:39.32194 |
description | A common application of ISO-TP or ISO 15762-2 is for example Unified Diagnostic Services (UDS) used in automotive ECUs for diagnostics. |
homepage | https://github.com/marcelbuesing/socketcan-isotp |
repository | https://github.com/marcelbuesing/socketcan-isotp.git |
max_upload_size | |
id | 188223 |
size | 44,458 |
SocketCAN ISO-TP crate. Based on socketcan-rs and isotp.h.
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 or ISO 15762-2 allows sending data packets that exceed the eight byte of a default CAN frame. A common application of ISO-TP is for example Unified Diagnostic Services (UDS) used in automotive ECUs for diagnostics.
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::{self, IsoTpSocket, StandardId};
fn main() -> Result<(), socketcan_isotp::Error> {
let mut tp_socket = IsoTpSocket::open(
"vcan0",
StandardId::new(0x123).expect("Invalid src id"),
StandardId::new(0x321).expect("Invalid dst id"),
)?;
let buffer = tp_socket.read()?;
println!("read {} bytes", buffer.len());
for x in buffer {
print!("{:X?} ", x);
}
println!("");
Ok(())
}
Setup Isotp Kernel Module: https://github.com/hartkopp/can-isotp
Setup virtual can interface.
sudo modprobe vcan && \
sudo ip link add dev vcan0 type vcan && \
sudo ip link set up vcan0