candev_linux.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 OTA keys S.A.
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #if defined(__linux__) /* SocketCAN is supported only on Linux */ || defined(DOXYGEN)
28 
29 # include <stdbool.h>
30 
31 # include "can/device.h"
32 # include "can/candev.h"
33 # include "mutex.h"
34 
38 # define CAN_MAX_SIZE_INTERFACE_NAME (5)
39 
43 typedef struct candev_conf {
47 
49 # define HAVE_CAN_CONF_T
50 
51 # if !defined(CANDEV_LINUX_MAX_FILTERS_RX) || defined(DOXYGEN)
53 # define CANDEV_LINUX_MAX_FILTERS_RX (16)
54 # endif
55 
56 # if !defined(CANDEV_LINUX_DEFAULT_BITRATE) || defined(DOXYGEN)
58 # define CANDEV_LINUX_DEFAULT_BITRATE (500000)
59 # endif
60 
61 # if !defined(CANDEV_LINUX_DEFAULT_SPT) || defined(DOXYGEN)
63 # define CANDEV_LINUX_DEFAULT_SPT (875)
64 # endif
65 
69 typedef struct candev_linux {
71  int sock;
72  const can_conf_t *conf;
76 
78 # define HAVE_CAN_T
79 
84 
85 #endif /* defined(__linux__) */
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
Definitions for low-level CAN driver interface.
#define CAN_MAX_SIZE_INTERFACE_NAME
Maximum size of an interface name.
Definition: candev_linux.h:38
struct candev_conf can_conf_t
Linux candev configuration.
struct candev_linux can_t
The candev_linux struct.
#define CANDEV_LINUX_MAX_FILTERS_RX
Max number of rx filters which can be set.
Definition: candev_linux.h:53
Mutex for thread synchronization.
ESP CAN device configuration.
Definition: can_esp.h:84
Controller Area Network filter.
Definition: can.h:128
Linux candev configuration.
Definition: candev_linux.h:43
char interface_name[CAN_MAX_SIZE_INTERFACE_NAME+1]
local interface name
Definition: candev_linux.h:45
The candev_linux struct.
Definition: candev_linux.h:69
const can_conf_t * conf
device configuration
Definition: candev_linux.h:72
int sock
local socket id
Definition: candev_linux.h:71
candev_t candev
candev base structure
Definition: candev_linux.h:70
struct can_filter filters[CANDEV_LINUX_MAX_FILTERS_RX]
filter list
Definition: candev_linux.h:74
Structure to hold driver state.
Definition: candev.h:76
Definitions of CAN device interface.
#define CAN_DLL_NUMOF
Maximum number of interfaces which can be registered on DLL.
Definition: device.h:48