candev_linux.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 OTA keys S.A.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef CANDEV_LINUX_H
24 #define CANDEV_LINUX_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #if defined(__linux__) /* SocketCAN is supported only on Linux */ || defined(DOXYGEN)
31 
32 #include <stdbool.h>
33 
34 #include "can/candev.h"
35 #include "mutex.h"
36 
40 #define CAN_MAX_SIZE_INTERFACE_NAME (5)
41 
45 typedef struct candev_conf {
48 } can_conf_t;
49 
51 #define HAVE_CAN_CONF_T
52 
53 #ifndef CANDEV_LINUX_MAX_FILTERS_RX
54 
57 #define CANDEV_LINUX_MAX_FILTERS_RX (16)
58 #endif
59 
60 #ifndef CANDEV_LINUX_DEFAULT_BITRATE
61 
64 #define CANDEV_LINUX_DEFAULT_BITRATE (500000)
65 #endif
66 
67 #ifndef CANDEV_LINUX_DEFAULT_SPT
68 
71 #define CANDEV_LINUX_DEFAULT_SPT (875)
72 #endif
73 
77 typedef struct candev_linux {
79  int sock;
80  const can_conf_t *conf;
83 } can_t;
84 
86 #define HAVE_CAN_T
87 
92 
93 #endif /* defined(__linux__) */
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* CANDEV_LINUX_H */
100 
candev
Structure to hold driver state.
Definition: candev.h:78
candev_conf
Linux candev configuration.
Definition: candev_linux.h:45
CAN_MAX_SIZE_INTERFACE_NAME
#define CAN_MAX_SIZE_INTERFACE_NAME
Maximum size of an interface name.
Definition: candev_linux.h:40
CAN_DLL_NUMOF
#define CAN_DLL_NUMOF
Maximum number of interfaces which can be registered on DLL.
Definition: device.h:49
can_filter
Controller Area Network filter.
Definition: can.h:101
CANDEV_LINUX_MAX_FILTERS_RX
#define CANDEV_LINUX_MAX_FILTERS_RX
Max number of rx filters which can be set.
Definition: candev_linux.h:57
can_conf_t
ESP CAN device configuration.
Definition: can_esp.h:98
candev.h
Definitions for low-level CAN driver interface.
mutex.h
Mutex for thread synchronization.
candev_linux
The candev_linux struct.
Definition: candev_linux.h:77
candev_linux::sock
int sock
local socket id
Definition: candev_linux.h:79
can_t
struct candev_linux can_t
The candev_linux struct.
can_conf_t
struct candev_conf can_conf_t
Linux candev configuration.
candev_linux::filters
struct can_filter filters[CANDEV_LINUX_MAX_FILTERS_RX]
filter list
Definition: candev_linux.h:82
candev_conf::interface_name
char interface_name[CAN_MAX_SIZE_INTERFACE_NAME+1]
local interface name
Definition: candev_linux.h:47
candev_linux::conf
const can_conf_t * conf
device configuration
Definition: candev_linux.h:80
candev_linux::candev
candev_t candev
candev base structure
Definition: candev_linux.h:78