a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright (C) 2016 OTA keys S.A.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_candev_linux SocketCAN driver
* @ingroup drivers_can
* @brief Implementation of simulated CAN controller driver using SocketCAN on Linux
* @{
*
* @file
* @brief Implementation of simulated CAN controller driver using SocketCAN on Linux
*
* @author Hermann Lelong <hermann@otakeys.com>
* @author Aurelien Gonce <aurelien.gonce@altran.com>
* @author Vincent Dupont <vincent@otakeys.com>
*/
#ifndef CANDEV_LINUX_H
#define CANDEV_LINUX_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__linux__) /* SocketCAN is supported only on Linux */ || defined(DOXYGEN)
#include <stdbool.h>
#include "can/candev.h"
#include "mutex.h"
/**
* Maximum size of an interface name
*/
#define CAN_MAX_SIZE_INTERFACE_NAME (5)
/**
* Linux candev configuration
*/
typedef struct candev_linux_conf {
/** local interface name */
char interface_name[CAN_MAX_SIZE_INTERFACE_NAME + 1];
} candev_linux_conf_t;
#ifndef CANDEV_LINUX_MAX_FILTERS_RX
/**
* Max number of rx filters which can be set
*/
#define CANDEV_LINUX_MAX_FILTERS_RX (16)
#endif
#ifndef CANDEV_LINUX_DEFAULT_BITRATE
/**
* Default bitrate setup
*/
#define CANDEV_LINUX_DEFAULT_BITRATE (500000)
#endif
#ifndef CANDEV_LINUX_DEFAULT_SPT
/**
* Default sampling point setup
*/
#define CANDEV_LINUX_DEFAULT_SPT (875)
#endif
/**
* @brief The candev_linux struct
*/
typedef struct candev_linux {
candev_t candev; /**< candev base structure */
int sock; /**< local socket id */
const candev_linux_conf_t *conf; /**< device configuration */
/** filter list */
struct can_filter filters[CANDEV_LINUX_MAX_FILTERS_RX];
} candev_linux_t;
/**
* @brief Device specific initialization function
*
* @param[inout] dev the device to initialize
* @param[in] conf the device configuration
*
* @return 0 on success
*/
int candev_linux_init(candev_linux_t *dev, const candev_linux_conf_t *conf);
/**
* @brief Array containing socketCAN device names
*/
extern candev_linux_conf_t candev_linux_conf[CAN_DLL_NUMOF];
#endif /* defined(__linux__) */
#ifdef __cplusplus
}
#endif
#endif /* CANDEV_LINUX_H */
/** @} */
|