The CAN bus in Linux

As seen earlier, every CAN controller is represented in the system as a network device, and it can be listed as any other Ethernet or Wi-Fi device using the ifconfig command (or equivalent). The reason is that a CAN bus is just a network of several machines that are able to talk to each other into a LAN.

So, as we already saw earlier, we can use all networking commands on these devices. Here are two examples using both ifconfig and ip commands:

root@a5d3:~# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) ...

Get GNU/Linux Rapid Embedded Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.