conn interface for CAN stack More...

Detailed Description

conn interface for CAN stack

This is the user interface to send and receive raw CAN frames or ISO-TP datagrams

Files

file  isotp.h
 Definitions of generic CAN interface.
 
file  raw.h
 Definitions of generic CAN interface.
 

Data Structures

struct  conn_can_raw
 RAW CAN connection. More...
 

Macros

#define CONN_CAN_RAW_MBOX_SIZE   (16)
 Mailbox size of a conn_can_raw_t.
 

Typedefs

typedef struct conn_can_raw conn_can_raw_t
 RAW CAN connection.
 

Functions

int conn_can_raw_create (conn_can_raw_t *conn, struct can_filter *filter, size_t count, int ifnum, int flags)
 Create can connection socket. More...
 
int conn_can_raw_close (conn_can_raw_t *conn)
 Close can connection socket. More...
 
int conn_can_raw_recv (conn_can_raw_t *conn, struct can_frame *frame, uint32_t timeout)
 Generic can receive. More...
 
int conn_can_raw_send (conn_can_raw_t *conn, const struct can_frame *frame, int flags)
 Generic can send. More...
 
int conn_can_raw_set_filter (conn_can_raw_t *conn, struct can_filter *filter, size_t count)
 Set raw CAN filters. More...
 

flags values

#define CONN_CAN_DONTWAIT   (1)
 Do not wait for Tx confirmation when sending.
 
#define CONN_CAN_RECVONLY   (2)
 Do not send anything on the bus.
 

Function Documentation

◆ conn_can_raw_close()

int conn_can_raw_close ( conn_can_raw_t conn)

Close can connection socket.

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

◆ conn_can_raw_create()

int conn_can_raw_create ( conn_can_raw_t conn,
struct can_filter filter,
size_t  count,
int  ifnum,
int  flags 
)

Create can connection socket.

Parameters
[in,out]connCAN connection
[in]filterlist of filters to set
[in]countnumber of filters in filter
[in]ifnumcan device Interface
[in]flagsconn flags to set (CONN_CAN_RECVONLY)
Postcondition
filter must remain allocated until conn is closed
Returns
0 if socket was successfully connected
any other negative number in case of an error

◆ conn_can_raw_recv()

int conn_can_raw_recv ( conn_can_raw_t conn,
struct can_frame frame,
uint32_t  timeout 
)

Generic can receive.

Parameters
[in]connCAN connection
[out]frameCAN frame to receive
[in]timeouttimeout in us, 0 for infinite
Returns
the number of bytes received
any other negative number in case of an error

◆ conn_can_raw_send()

int conn_can_raw_send ( conn_can_raw_t conn,
const struct can_frame frame,
int  flags 
)

Generic can send.

Parameters
[in]connCAN connection
[in]frameframe to send
[in]flagsmake function blocked or not (CONN_CAN_DONTWAIT to ignore tx confirmation)
Returns
the number of bytes sent
any other negative number in case of an error

◆ conn_can_raw_set_filter()

int conn_can_raw_set_filter ( conn_can_raw_t conn,
struct can_filter filter,
size_t  count 
)

Set raw CAN filters.

If filters were already set for this connection, it first unsets the previous filters and sets the new ones.

Parameters
[in]connCAN connection
[in]filterlist of filters to set
[in]countnumber of filters in filter
Precondition
previously set filters must be allocated until the end of the call
Postcondition
filter must remain allocated until conn is closed or conn_can_raw_set_filter() is called
Returns
0 if can filters were successfully set
any other negative number in case of an error