IOU04 Quick-Start-Guide / SocketCAN Demo

SocketCAN Demo

In this demo, we’ll demonstrate how to receive data from a CAN bus and print it to the console. This demo is using the Linux SocketCAN framework.



  • A Moducop Edge Computer with a IOU04 installed
  • A development PC (Windows or Linux), connected via Network to the Moducop
  • CANbus with at least one CAN device
  • Cable to connect the CAN device with the IOU04

Find your Service Name

First, find out your service name. The IOU04’s CAN Interface service name depends on the ModuCop’s slot and is usually IOU04-USB-EXT-<slot-number>-can.

If you are unsure, you can also browse the available devices:

ssh root@<moducop-ip>

Once logged in into the Moducop Shell:

io4edge-cli scan -f

If your IOU04 is in the slot next to the CPU, the output should be:

S101-IOU04-USB-EXT-1,, S101-IOU04, <serial-number>
|    SERVICE TYPE     |       SERVICE NAME        | PORT  |
| _ttynvt._tcp        | S101-IOU04-USB-EXT-1-com1 | 10000 |
| _ttynvt._tcp        | S101-IOU04-USB-EXT-1-com2 | 10001 |
| _io4edge_canL2._tcp | S101-IOU04-USB-EXT-1-can  | 10002 |

Bus Configuration

Bus Configuration must be set once to tell the IOU04 about the CAN parameters. This configuration is saved persistently in the device. You only need to perform this configuration step once, it survives reboots and power cycles.

In this example, we assume your

  • Bitrate is 125 kBit
  • Sampling Point is 0.625 (62.5%)
  • Synchronization Jump Width is 1
  • Listen only mode is off (i.e. Normal operation)

Configure the device. You specify a string that has the form bitrate:sampling-point/1000:sjw:listen-only

On your Moducop, run:

io4edge-cli -d S101-IOU04-USB-EXT-1 set-parameter can-config 125000:625:1:0
# Restart to apply parameters
io4edge-cli -d S101-IOU04-USB-EXT-1 restart


CAN Connection

Connect CAN_L, CAN_H and GND_ISO to the CAN bus. Be sure to have correct termination of 120R at each end of the line.

Create a socketCAN instance

To access the IOU04 via socketCAN, we create a virtual socketCAN network that matches the service name of your IOU04 CAN Interface.

The virtual socket CAN network must be named according to IOU04 CAN Interface service name. E.g. if the service name is MYDEV-can, the virtual socketCAN device must be named vcanMYDEV (without -can). Because network interface names can have only max. 15 characters, but service names can be longer, there is a rule to map longer service names to socketCAN device names:



  • Service Name S101-IOU04-USB-EXT-1-can -> vcan name vcanS101xxEXT-1
  • Service Name 123456789012-can -> vcan name vcan1234xx89012
  • Service Name MIO04-1-can -> vcan name vcanMIO04-1

Now, create a virtual socketCAN network. On your Moducop, execute:

ip link add dev vcanS101xxEXT-1 type vcan
ip link set up vcanS101xxEXT-1

Function Test

Using the candump tool (part of can-utils package), you should see all frames that are sent on the CAN bus. Example (would dump also error information from CANbus):

./candump vcanS101xxEXT-1 vcanS101xxEXT-1,1FFFFFFF:1FFFFFFF,#FFFFFFFF -e
  vcanS101xxEXT-1  6B6   [5]  37 67 2F 0F F2
  vcanS101xxEXT-1  24A   [6]  B1 39 8A 3A A5 77
  vcanS101xxEXT-1  57C   [5]  01 B2 9F 37 22
  vcanS101xxEXT-1  665   [8]  1C C2 60 0A 8E E3 85 42
  vcanS101xxEXT-1  18B   [5]  B0 E5 E4 2E 24
  vcanS101xxEXT-1  0D0   [8]  64 49 45 71 6B B2 6E 09
  vcanS101xxEXT-1  146   [7]  2E A6 CF 44 1A E9 2A
  vcanS101xxEXT-1  508   [0]
  vcanS101xxEXT-1  726   [8]  B0 B5 2E 62 70 89 78 4F
  vcanS101xxEXT-1  454   [2]  15 01