zephyr/samples/net/sockets/can
Jukka Rissanen 03c5c0f818 samples: net: Disable native_posix target in more samples
The native_posix compilations fail with various socket
errors like this:

samples/net/sockets/can/src/main.c:65:9: error: implicit \
     declaration of function ‘send’ [-Werror=implicit-function-declaration]
     65 |   ret = send(fd, &sframe, sizeof(sframe), 0);
        |         ^~~~

So disable the native_posix board from networking samples as
native_posix board is not compatible with CONFIG_POSIX_API

This is related to commit b8fc1c4c3e ("samples: net: Disable
native_posix target in samples") but disables more network samples
for native_posix board.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-04-17 14:28:08 +02:00
..
boards boards: posix: native_posix: enable can_loopback0 by default 2022-10-03 10:17:12 +02:00
src drivers: can: remove run-time RTR filtering, add build-time RTR filter 2024-01-21 11:00:31 +01:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Kconfig samples: net: sockets: socketCAN: add loopback mode 2022-04-08 09:31:51 +02:00
prj.conf samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00
README.rst samples: net: doc: Use new Sphinx extension to document networking samples 2023-09-19 15:22:59 +01:00
sample.yaml samples: net: Disable native_posix target in more samples 2024-04-17 14:28:08 +02:00

.. zephyr:code-sample:: socket-can
   :name: SocketCAN
   :relevant-api: bsd_sockets socket_can

   Send and receive raw CAN frames using BSD sockets API.

Overview
********

The socket CAN sample is a server/client application that sends and receives
raw CAN frames using BSD socket API.

The application consists of these functions:

* Setup function which creates a CAN socket, binds it to a CAN network
  interface, and then installs a CAN filter to the socket so that the
  application can receive CAN frames.
* Receive function which starts to listen the CAN socket and prints
  information about the CAN frames.
* Send function which starts to send raw CAN frames to the bus.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/can`.

Requirements
************

You need a CANBUS enabled board like :ref:`nucleo_l432kc_board` or
:ref:`stm32f072b_disco_board`.

Building and Running
********************

Build the socket CAN sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/can
   :board: <board to use>
   :conf: <config file to use>
   :goals: build
   :compact:

Example building for the nucleo_l432kc:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/can
   :host-os: unix
   :board: nucleo_l432kc
   :goals: run
   :compact: