zephyr/samples/net/sockets/can
Kumar Gala 6defabebad drivers: can: Fix building with socket_can_generic.h
socket_can_generic.h makes some assumptions that are not always valid
for various drivers with regards to numbering.  To clean this up we
add defines for SOCKET_CAN_NAME_0 and SOCKET_CAN_NAME_2 in addition to
SOCKET_CAN_NAME_1.

We also move struct socket_can_context into the drivers themselves
since they know best how many CAN interfaces are getting supported and
what naming/number convention they'd have.

Additionally, this also exposes a few other build issues with the
can_mcux_flexcan driver that get fixed.

Finally, we remove the platform_allow from samples/net/sockets/can
since it is no longer needed.

Fixes #31733

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-02 16:46:28 -05:00
..
boards
src drivers: can: rework zcan_frame and zcan_filter 2020-12-17 11:07:53 +01:00
CMakeLists.txt samples: make find_package(Zephyr...) REQUIRED 2020-05-29 10:47:25 +02:00
README.rst samples: net: can: Readme file was missing 2019-03-13 15:57:48 -05:00
prj.conf logging: Revamp menuconfig 2021-01-26 06:15:42 -05:00
sample.yaml drivers: can: Fix building with socket_can_generic.h 2021-02-02 16:46:28 -05:00

README.rst

.. _socket-can-sample:

Socket CAN
##########

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: