Loading...
Searching...
No Matches
isotp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 OTA keys S.A.
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include "compiler_hints.h"
24#include "can/can.h"
25#include "can/isotp.h"
26#include "mbox.h"
27
28#if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
29#include "mutex.h"
30
31#ifndef CONN_CAN_ISOTP_MBOX_SIZE
35#define CONN_CAN_ISOTP_MBOX_SIZE (16)
36#endif
37
48
63
81
95{
96 slave->next = NULL;
97 slave->master = master;
98 slave->rx = NULL;
99}
100#else
101
102#ifndef CONN_CAN_ISOTP_MBOX_SIZE
106#define CONN_CAN_ISOTP_MBOX_SIZE (16)
107#endif
108
112typedef struct conn_can_isotp {
113 struct isotp isotp;
114 int ifnum;
115 int bound;
116 mbox_t mbox;
118 msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE];
120#endif /* MODULE_CONN_CAN_ISOTP_MULTI */
121
132int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum);
133
144
154
166ACCESS(write_only, 2, 3)
167int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout);
168
181ACCESS(read_only, 2, 3)
182int 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)
195 uint32_t timeout);
196#endif
197
198#ifdef __cplusplus
199}
200#endif
201
Common macros and compiler attributes/pragmas configuration.
#define ACCESS(mode, ptr_idx, size_idx)
Emit an attribute (if supported by the compiler) that declares how a function will access its paramet...
int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout)
Receive isotp data.
int conn_can_isotp_close(conn_can_isotp_t *conn)
Close can isotp connection socket.
int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum)
Create can isotp connection socket.
#define CONN_CAN_ISOTP_MBOX_SIZE
Mailbox size of a conn_can_isotp_t.
Definition isotp.h:35
struct conn_can_isotp_master conn_can_isotp_t
ISO-TP connection.
Definition isotp.h:47
int conn_can_isotp_bind(conn_can_isotp_t *conn, struct isotp_fc_options *fc_options)
Bind a can isotp connection.
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:93
struct conn_can_isotp_slave conn_can_isotp_slave_t
ISO-TP salve connection.
int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags)
Generic can send.
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.
struct can_rx_data can_rx_data_t
Received data structure.
ISO TP high level interface.
Mailbox API.
Mutex for thread synchronization.
ISO-TP master connection.
Definition isotp.h:67
int bound
1 if connection is bound
Definition isotp.h:73
msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE]
Connection list message queue.
Definition isotp.h:79
mbox_t mbox
mailbox for the connection list
Definition isotp.h:77
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:71
struct conn_can_isotp_slave * next
First slave in the list.
Definition isotp.h:69
struct conn_can_isotp_master * master
Master connection.
Definition isotp.h:70
int ifnum
interface number
Definition isotp.h:72
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:74
mutex_t lock
Master lock.
Definition isotp.h:76
ISO-TP salve connection.
Definition isotp.h:55
int ifnum
interface number
Definition isotp.h:59
struct conn_can_isotp_slave * next
Next slave in the list.
Definition isotp.h:56
int bound
1 if connection is bound
Definition isotp.h:60
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:61
struct conn_can_isotp_master * master
Master connection holding the mailbox.
Definition isotp.h:57
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:58
The isotp_fc_options struct.
Definition isotp.h:57
The isotp_options struct.
Definition isotp.h:75
Mailbox struct definition.
Definition mbox.h:38
Describes a message object which can be sent between threads.
Definition msg.h:193
Mutex structure.
Definition mutex.h:36
Definitions high-level CAN interface.