Virtual Socket-CAN

How to create several virtual sockets and link them together to create a virtual bus?

I want to simulate an application in which many nodes exchange data via CAN.

+4
source share
1 answer

All you need is a cangw tool from can-utils . Create two virtual interfaces:

ip link add dev vcan0 type vcan
ip link add dev vcan1 type vcan
ip link set up vcan0
ip link set up vcan1

Create a routing rule so that all packets included in vcan0 are sent to vcan1 :

cangw -A -s vcan0 -d vcan1 -e

Listen to vcan1 in one terminal:

candump vcan1

And send the packet from another terminal:

cansend vcan0 123#0011

You will see that candump will receive this CAN packet:

vcan1  123   [2]  00 11
+5
source

Source: https://habr.com/ru/post/1614792/


All Articles