conn/isotp.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 
20 #ifndef CAN_CONN_ISOTP_H
21 #define CAN_CONN_ISOTP_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "can/can.h"
28 #include "can/isotp.h"
29 #include "mbox.h"
30 
31 #if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
32 #include "mutex.h"
33 
34 #ifndef CONN_CAN_ISOTP_MBOX_SIZE
35 
38 #define CONN_CAN_ISOTP_MBOX_SIZE (16)
39 #endif
40 
51 
58 typedef struct conn_can_isotp_slave {
61  struct isotp isotp;
62  int ifnum;
63  int bound;
66 
71  /* slave fields */
74  struct isotp isotp;
75  int ifnum;
76  int bound;
78  /* slave fields end */
83 };
84 
97 {
98  slave->next = NULL;
99  slave->master = master;
100  slave->rx = NULL;
101 }
102 #else
103 
104 #ifndef CONN_CAN_ISOTP_MBOX_SIZE
105 
108 #define CONN_CAN_ISOTP_MBOX_SIZE (16)
109 #endif
110 
114 typedef struct conn_can_isotp {
115  struct isotp isotp;
116  int ifnum;
117  int bound;
118  mbox_t mbox;
120  msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE];
122 #endif /* MODULE_CONN_CAN_ISOTP_MULTI */
123 
134 int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum);
135 
145 
155 
167 int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout);
168 
181 int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags);
182 
183 #if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
184 
194 #endif
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* CAN_CONN_ISOTP_H */
201 
can_rx_data_t * rx
Buffered rx data.
Definition: conn/isotp.h:77
struct conn_can_isotp_master * master
Master connection holding the mailbox.
Definition: conn/isotp.h:60
Mailbox struct definition.
Definition: mbox.h:39
int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout)
Receive isotp data.
Mailbox API.
struct conn_can_isotp_master * master
Master connection.
Definition: conn/isotp.h:73
Received data structure.
ISO-TP salve connection.
Definition: conn/isotp.h:58
#define CONN_CAN_ISOTP_MBOX_SIZE
Mailbox size of a conn_can_isotp_t.
Definition: conn/isotp.h:38
int bound
1 if connection is bound
Definition: conn/isotp.h:63
struct conn_can_isotp_slave conn_can_isotp_slave_t
ISO-TP salve connection.
The isotp_options struct.
Definition: isotp.h:58
static void conn_can_isotp_init_slave(conn_can_isotp_t *master, conn_can_isotp_slave_t *slave)
Initialize a slave connection.
Definition: conn/isotp.h:96
int conn_can_isotp_close(conn_can_isotp_t *conn)
Close can isotp connection socket.
int conn_can_isotp_select(conn_can_isotp_slave_t **conn, conn_can_isotp_t *master, uint32_t timeout)
Wait for reception from multiple connections.
int bound
1 if connection is bound
Definition: conn/isotp.h:76
struct conn_can_isotp_slave * next
Next slave in the list.
Definition: conn/isotp.h:59
ISO-TP master connection.
Definition: conn/isotp.h:70
int conn_can_isotp_bind(conn_can_isotp_t *conn)
Bind a can isotp connection.
int ifnum
interface number
Definition: conn/isotp.h:62
struct conn_can_isotp_slave * next
First slave in the list.
Definition: conn/isotp.h:72
ISO TP high level interface.
Describes a message object which can be sent between threads.
Definition: msg.h:184
struct conn_can_isotp_master conn_can_isotp_t
ISO-TP connection.
Definition: conn/isotp.h:50
mbox_t mbox
mailbox for the connection list
Definition: conn/isotp.h:80
RIOT synchronization API.
mutex_t lock
Master lock.
Definition: conn/isotp.h:79
int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags)
Generic can send.
int ifnum
interface number
Definition: conn/isotp.h:75
Mutex structure.
Definition: mutex.h:36
int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum)
Create can isotp connection socket.
The isotp struct.
Definition: isotp.h:86
can_rx_data_t * rx
Buffered rx data.
Definition: conn/isotp.h:64
Definitions high-level CAN interface.