Linux Kernel Module

Linux Kernel Module#

Overview#

  • Sources at hartkopp/can-isotp

  • Part of Linux Mainline since Linux version 5.10

  • can-isotp is a Linux Kernel module which extends SocketCAN with ISO-TP functionality

  • All transport layer operations are done in the Kernel space

  • Users can open an ISOTP Socket and directly send and receive data. No CAN frames need to be generated by the user.

../../_images/can-isotp-overview.png

Fig. 47 Overview of Linux CAN.#

Author: Dr. Oliver Hartkopp

Figure from [Har15].

Utilities#

  • Loading the kernel module:

sudo modprobe can-isotp
  • Linux can-utils comes with handy utilities for ISOTP

    • isotpsend: Send PDUs from stdin to CAN

    • isotprecv: print received PDU to stdout

    • isotpdump: dump CAN frames with PCI decoding

    • isotpsniffer: dump reassembled ISO-TP PDUs

    • isotptun: create an IP tunnel over unreliable ISO-TP PDUs

Utility examples#

All examples use vcan0 as interface name!

  • Send an ISOTP PDU

echo "12 34 56" | isotpsend vcan0 -s 123 -d 321
echo "12 34 56 aa bb cc dd ee ff gg" | isotpsend vcan0 -s 123 -d 321
  • Receive an ISOTP PDU

isotprecv vcan0 -s 321 -d 123

12 34 56

isotprecv vcan0 -s 321 -d 123

12 34 56 AA BB CC DD EE FF
  • Sniff ISOTP PDUs

isotpsniffer vcan0 -s 123 -d 321

 vcan0  123  [3]  12 34 56  - '.4V'
 vcan0  123  [9]  12 34 56 AA BB CC DD EE FF  - '.4V......'
  • Sniff CAN frames with ISOTP decoding

isotpdump vcan0 -s 123 -d 321

 vcan0  123  [4]  [SF] ln: 3    data: 12 34 56
 vcan0  123  [8]  [FF] ln: 9    data: 12 34 56 AA BB CC 
 vcan0  321  [3]  [FC] FC: 0=CTS BS: 0=off STmin: 0x00=0ms
 vcan0  123  [4]  [CF] sn: 1    data: DD EE FF