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/device.h"
35 # include "can/candev.h"
36 # include "mutex.h"
37 
41 # define CAN_MAX_SIZE_INTERFACE_NAME (5)
42 
46 typedef struct candev_conf {
50 
52 # define HAVE_CAN_CONF_T
53 
54 # if !defined(CANDEV_LINUX_MAX_FILTERS_RX) || defined(DOXYGEN)
56 # define CANDEV_LINUX_MAX_FILTERS_RX (16)
57 # endif
58 
59 # if !defined(CANDEV_LINUX_DEFAULT_BITRATE) || defined(DOXYGEN)
61 # define CANDEV_LINUX_DEFAULT_BITRATE (500000)
62 # endif
63 
64 # if !defined(CANDEV_LINUX_DEFAULT_SPT) || defined(DOXYGEN)
66 # define CANDEV_LINUX_DEFAULT_SPT (875)
67 # endif
68 
72 typedef struct candev_linux {
74  int sock;
75  const can_conf_t *conf;
79 
81 # define HAVE_CAN_T
82 
87 
88 #endif /* defined(__linux__) */
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* CANDEV_LINUX_H */
Definitions for low-level CAN driver interface.
#define CAN_MAX_SIZE_INTERFACE_NAME
Maximum size of an interface name.
Definition: candev_linux.h:41
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:56
Mutex for thread synchronization.
ESP CAN device configuration.
Definition: can_esp.h:88
Controller Area Network filter.
Definition: can.h:129
Linux candev configuration.
Definition: candev_linux.h:46
char interface_name[CAN_MAX_SIZE_INTERFACE_NAME+1]
local interface name
Definition: candev_linux.h:48
The candev_linux struct.
Definition: candev_linux.h:72
const can_conf_t * conf
device configuration
Definition: candev_linux.h:75
int sock
local socket id
Definition: candev_linux.h:74
candev_t candev
candev base structure
Definition: candev_linux.h:73
struct can_filter filters[CANDEV_LINUX_MAX_FILTERS_RX]
filter list
Definition: candev_linux.h:77
Structure to hold driver state.
Definition: candev.h:77
Definitions of CAN device interface.
#define CAN_DLL_NUMOF
Maximum number of interfaces which can be registered on DLL.
Definition: device.h:49