Loading...
Searching...
No Matches
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
9#pragma once
10
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include "can/can.h"
27#include "can/isotp.h"
28#include "mbox.h"
29
30#if defined(MODULE_CONN_CAN_ISOTP_MULTI) || defined(DOXYGEN)
31#include "mutex.h"
32
33#ifndef CONN_CAN_ISOTP_MBOX_SIZE
37#define CONN_CAN_ISOTP_MBOX_SIZE (16)
38#endif
39
50
65
83
96{
97 slave->next = NULL;
98 slave->master = master;
99 slave->rx = NULL;
100}
101#else
102
103#ifndef CONN_CAN_ISOTP_MBOX_SIZE
107#define CONN_CAN_ISOTP_MBOX_SIZE (16)
108#endif
109
113typedef struct conn_can_isotp {
114 struct isotp isotp;
115 int ifnum;
116 int bound;
117 mbox_t mbox;
119 msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE];
121#endif /* MODULE_CONN_CAN_ISOTP_MULTI */
122
133int conn_can_isotp_create(conn_can_isotp_t *conn, struct isotp_options *options, int ifnum);
134
145
155
167int conn_can_isotp_recv(conn_can_isotp_t *conn, void *buf, size_t size, uint32_t timeout);
168
181int 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)
193int conn_can_isotp_select(conn_can_isotp_slave_t **conn, conn_can_isotp_t *master, uint32_t timeout);
194#endif
195
196#ifdef __cplusplus
197}
198#endif
199
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:37
struct conn_can_isotp_master conn_can_isotp_t
ISO-TP connection.
Definition isotp.h:49
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:95
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:69
int bound
1 if connection is bound
Definition isotp.h:75
msg_t mbox_queue[CONN_CAN_ISOTP_MBOX_SIZE]
Connection list message queue.
Definition isotp.h:81
mbox_t mbox
mailbox for the connection list
Definition isotp.h:79
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:73
struct conn_can_isotp_slave * next
First slave in the list.
Definition isotp.h:71
struct conn_can_isotp_master * master
Master connection.
Definition isotp.h:72
int ifnum
interface number
Definition isotp.h:74
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:76
mutex_t lock
Master lock.
Definition isotp.h:78
ISO-TP salve connection.
Definition isotp.h:57
int ifnum
interface number
Definition isotp.h:61
struct conn_can_isotp_slave * next
Next slave in the list.
Definition isotp.h:58
int bound
1 if connection is bound
Definition isotp.h:62
can_rx_data_t * rx
Buffered rx data.
Definition isotp.h:63
struct conn_can_isotp_master * master
Master connection holding the mailbox.
Definition isotp.h:59
struct isotp isotp
ISO-TP parameters and status.
Definition isotp.h:60
The isotp_fc_options struct.
Definition isotp.h:59
The isotp_options struct.
Definition isotp.h:77
Mailbox struct definition.
Definition mbox.h:40
Describes a message object which can be sent between threads.
Definition msg.h:195
Mutex structure.
Definition mutex.h:39
Definitions high-level CAN interface.