SocketCAN on Native Simulator Snippet (socketcan-native-sim)

west build -S socketcan-native-sim [...]

Overview

This snippet allows to configure Controller Area Network (CAN) samples with Linux SocketCAN support on native_sim.

By default, the native simulator expects a SocketCAN network device called zcan0 (specified in boards/native/native_sim/native_sim.dts). This name can be added as an alternative name for an existing SocketCAN network device (here, a newly created virtual CAN network device vcan0) using a command like the following:

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link property add dev vcan0 altname zcan0

The SocketCAN device must be configured and brought up before running the native simulator:

sudo ip link set vcan0 up