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 "can/can.h"
24#include "can/isotp.h"
25#include "mbox.h"
26
27#if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
28#include "mutex.h"
29
30#ifndef CONN_CAN_ISOTP_MBOX_SIZE
34#define CONN_CAN_ISOTP_MBOX_SIZE (16)
35#endif
36
47
62
80
93{
94 slave->next = NULL;
95 slave->master = master;
96 slave->rx = NULL;
97}
98#else
99
100#ifndef CONN_CAN_ISOTP_MBOX_SIZE
104#define CONN_CAN_ISOTP_MBOX_SIZE (16)
105#endif
106
110typedef struct conn_can_isotp {
111 struct isotp isotp;
112 int ifnum;
113 int bound;
114 mbox_t mbox;
116 msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE];
118#endif /* MODULE_CONN_CAN_ISOTP_MULTI */
119
130int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum);
131
142
152
164int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout);
165
178int conn_can_isotp_send(conn_can_isotp_t *conn, const void *buf, size_t size, int flags);
179
180#if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
190int conn_can_isotp_select(conn_can_isotp_slave_t **conn, conn_can_isotp_t *master, uint32_t timeout);
191#endif
192
193#ifdef __cplusplus
194}
195#endif
196
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:34
struct conn_can_isotp_master conn_can_isotp_t
ISO-TP connection.
Definition isotp.h:46
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:92
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:66
int bound
1 if connection is bound
Definition isotp.h:72
msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE]
Connection list message queue.
Definition isotp.h:78
mbox_t mbox
mailbox for the connection list
Definition isotp.h:76
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:70
struct conn_can_isotp_slave * next
First slave in the list.
Definition isotp.h:68
struct conn_can_isotp_master * master
Master connection.
Definition isotp.h:69
int ifnum
interface number
Definition isotp.h:71
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:73
mutex_t lock
Master lock.
Definition isotp.h:75
ISO-TP salve connection.
Definition isotp.h:54
int ifnum
interface number
Definition isotp.h:58
struct conn_can_isotp_slave * next
Next slave in the list.
Definition isotp.h:55
int bound
1 if connection is bound
Definition isotp.h:59
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:60
struct conn_can_isotp_master * master
Master connection holding the mailbox.
Definition isotp.h:56
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:57
The isotp_fc_options struct.
Definition isotp.h:56
The isotp_options struct.
Definition isotp.h:74
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.