zephyr/snippets/socketcan-native-sim
Henrik Brix Andersen 81f5a801e3 snippets: add snippet for enabling SocketCAN support on native_sim
Add snippet for enabling Linux SocketCAN support on the native simulator.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-08-01 19:37:08 +01:00
..
README.rst
snippet.yml
socketcan-native-sim.conf
socketcan-native-sim.overlay

.. _snippet-socketcan-native-sim:

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

.. code-block:: console

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

Overview
********

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

By default, the native simulator expects a SocketCAN network device called ``zcan0`` (specified in
:zephyr_file:`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:

.. code-block:: console

   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:

.. code-block:: console

   sudo ip link set vcan0 up