Linux SocketCAN nano-howto

How to get it to work:

In the kernel, enable CAN networking and your appropriate CAN hardware device driver.
E.g., I have the dual-port Advantech PCI-1680, with a loopback (point-to-point interconnect, really) between the two ports.
I had to patch Linux 3.16.7 to get hardware support for this particular board.

modprobe plx_can
ip link set can0 type can bitrate 125000
ip link set can1 type can bitrate 125000
ifconfig can0 up
ifconfig can1 up

# the socketcan user-space tools have moved from SVN at Berlios to GIT at Github
aptitude install git
git clone
cd can-utils
make install

candump can1
# switch to another console
cansend can0 5A1#1122334455667788

All of this works "out of the box" in Debian 8.1 Jessie.
Yes, the netfilter's "ip" tool already knows about CAN.
And yes, the libc / kernheaders already contain the CAN #defines and structs.
It really all worked in Debian 6 Squeeze already.

For more information on how to use the "socket CAN" from your programs,
check out Documentation/networking/can.txt in your kernel source tree.
And, the can-utils directory is a great source of code examples.

blurted by: Frank Rysanek [ rysanek AT fccps DOT cz ]