Loading...
Searching...
No Matches

Definitions of generic CAN interface. More...

Detailed Description

Definitions of generic CAN interface.

Author
Vincent Dupont vince.nosp@m.nt@o.nosp@m.takey.nosp@m.s.co.nosp@m.m

Definition in file isotp.h.

#include "can/can.h"
#include "can/isotp.h"
#include "mbox.h"
#include "mutex.h"
+ Include dependency graph for isotp.h:

Go to the source code of this file.

Data Structures

struct  conn_can_isotp_slave
 ISO-TP salve connection. More...
 
struct  conn_can_isotp_master
 ISO-TP master connection. More...
 
#define CONN_CAN_ISOTP_MBOX_SIZE   (16)
 Mailbox size of a conn_can_isotp_t.
 
typedef struct conn_can_isotp_master conn_can_isotp_t
 ISO-TP connection.
 
typedef struct conn_can_isotp_slave conn_can_isotp_slave_t
 ISO-TP salve connection.
 
static void conn_can_isotp_init_slave (conn_can_isotp_t *master, conn_can_isotp_slave_t *slave)
 Initialize a slave connection.
 
int conn_can_isotp_create (conn_can_isotp_t *conn, struct isotp_options *options, int ifnum)
 Create can isotp connection socket.
 
int conn_can_isotp_bind (conn_can_isotp_t *conn, struct isotp_fc_options *fc_options)
 Bind a can isotp connection.
 
int conn_can_isotp_close (conn_can_isotp_t *conn)
 Close can isotp connection socket.
 
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_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.
 

Macro Definition Documentation

◆ CONN_CAN_ISOTP_MBOX_SIZE

#define CONN_CAN_ISOTP_MBOX_SIZE   (16)

Mailbox size of a conn_can_isotp_t.

Definition at line 38 of file isotp.h.

Typedef Documentation

◆ conn_can_isotp_slave_t

ISO-TP salve connection.

This is a slave connection which exists only when conn_can_isotp_multi module is used.

◆ conn_can_isotp_t

ISO-TP connection.

When conn_can_isotp_multi module is used, this is a 'master' connection which can be used to send and receive with multiple connections within a single thread.

If conn_can_isotp_multi is not used, this is a simple ISO-TP connection

Definition at line 50 of file isotp.h.

Function Documentation

◆ 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.

Parameters
[in,out]connISO-TP connection
[in]fc_optionsISO-TP flow control options, can be NULL for default parameters
Returns
0 on success
any other negative number in case of an error

◆ conn_can_isotp_close()

int conn_can_isotp_close ( conn_can_isotp_t conn)

Close can isotp connection socket.

Parameters
[in]connISO-TP connection
Returns
0 if conn is closed correctly
any other negative number in case of an error

◆ 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.

Parameters
[in,out]connISO-TP connection
[in]optionsISO-TP options
[in]ifnumcan device Interface
Returns
0 if socket was successfully connected
any other negative number in case of an error

◆ conn_can_isotp_init_slave()

static void conn_can_isotp_init_slave ( conn_can_isotp_t master,
conn_can_isotp_slave_t slave 
)
inlinestatic

Initialize a slave connection.

This initializes a slave connection.

This must be called on slave connections when conn_can_isotp_multi is used. Does not exist otherwise.

Parameters
[in]masterthe master connection
[in,out]slavethe slave connection to initialize

Definition at line 96 of file isotp.h.

◆ 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.

Parameters
[in]connISO-TP connection
[out]bufbuf to fill in with received data
[in]sizesize of the buffer in bytes
[in]timeouttimeout in us, 0 for infinite
Returns
the number of bytes received
any other negative number in case of an error

◆ 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.

Parameters
[out]connISO-TP connection which received data
[in]masterthe master connection
[in]timeouttimeout in us, 0 for infinite wait
Returns
0 if OK, < 0 if error

◆ 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.

Parameters
[in]connISO-TP connection
[in]bufdata to send
[in]sizesize of the buffer in bytes
[in]flagsmake function blocked or not (CAN_ISOTP_TX_DONT_WAIT to ignore tx confirmation)
Returns
the number of bytes sent
any other negative number in case of an error