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 int conn_can_isotp_bind(conn_can_isotp_t *conn, struct isotp_fc_options *fc_options);
146 
156 
168 int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout);
169 
182 int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags);
183 
184 #if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
185 
194 int conn_can_isotp_select(conn_can_isotp_slave_t **conn, conn_can_isotp_t *master, uint32_t timeout);
195 #endif
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif /* CAN_CONN_ISOTP_H */
202 
conn_can_isotp_slave
ISO-TP salve connection.
Definition: isotp.h:58
conn_can_isotp_master::rx
can_rx_data_t * rx
Buffered rx data.
Definition: isotp.h:77
can_rx_data
Received data structure.
Definition: common.h:122
isotp_options
The isotp_options struct.
Definition: isotp.h:78
conn_can_isotp_recv
int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout)
Receive isotp data.
can.h
Definitions high-level CAN interface.
conn_can_isotp_master
ISO-TP master connection.
Definition: isotp.h:70
conn_can_isotp_create
int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum)
Create can isotp connection socket.
conn_can_isotp_master::next
struct conn_can_isotp_slave * next
First slave in the list.
Definition: isotp.h:72
conn_can_isotp_master::lock
mutex_t lock
Master lock.
Definition: isotp.h:79
conn_can_isotp_master::master
struct conn_can_isotp_master * master
Master connection.
Definition: isotp.h:73
conn_can_isotp_slave::bound
int bound
1 if connection is bound
Definition: isotp.h:63
conn_can_isotp_slave::master
struct conn_can_isotp_master * master
Master connection holding the mailbox.
Definition: isotp.h:60
mbox_t
Mailbox struct definition.
Definition: mbox.h:41
isotp
The isotp struct.
Definition: isotp.h:106
mbox.h
Mailbox API.
conn_can_isotp_send
int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags)
Generic can send.
conn_can_isotp_t
struct conn_can_isotp_master conn_can_isotp_t
ISO-TP connection.
Definition: isotp.h:50
conn_can_isotp_slave::rx
can_rx_data_t * rx
Buffered rx data.
Definition: isotp.h:64
conn_can_isotp_bind
int conn_can_isotp_bind(conn_can_isotp_t *conn, struct isotp_fc_options *fc_options)
Bind a can isotp connection.
isotp_fc_options
The isotp_fc_options struct.
Definition: isotp.h:60
conn_can_isotp_close
int conn_can_isotp_close(conn_can_isotp_t *conn)
Close can isotp connection socket.
isotp.h
ISO TP high level interface.
conn_can_isotp_slave_t
struct conn_can_isotp_slave conn_can_isotp_slave_t
ISO-TP salve connection.
mutex.h
Mutex for thread synchronization.
conn_can_isotp_master::ifnum
int ifnum
interface number
Definition: isotp.h:75
conn_can_isotp_slave::ifnum
int ifnum
interface number
Definition: isotp.h:62
conn_can_isotp_slave::next
struct conn_can_isotp_slave * next
Next slave in the list.
Definition: isotp.h:59
conn_can_isotp_master::mbox
mbox_t mbox
mailbox for the connection list
Definition: isotp.h:80
CONN_CAN_ISOTP_MBOX_SIZE
#define CONN_CAN_ISOTP_MBOX_SIZE
Mailbox size of a conn_can_isotp_t.
Definition: isotp.h:38
conn_can_isotp_master::mbox_queue
msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE]
Connection list message queue.
Definition: isotp.h:82
msg_t
Describes a message object which can be sent between threads.
Definition: msg.h:185
conn_can_isotp_master::bound
int bound
1 if connection is bound
Definition: isotp.h:76
conn_can_isotp_select
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.
conn_can_isotp_init_slave
static void conn_can_isotp_init_slave(conn_can_isotp_t *master, conn_can_isotp_slave_t *slave)
Initialize a slave connection.
Definition: isotp.h:96
mutex_t
Mutex structure.
Definition: mutex.h:120