CAN-ETH C/C++ API  Version 2.0
CAN-ETH API Functions

This module documents the available CAN-ETH API functions. More...

Functions

int canEthInit (void)
 Initialises the CAN-ETH Ethernet interface. More...
 
void canEthShutdown (void)
 Shutdown the CAN-ETH Ethernet interface. More...
 
CanHandle canEthOpen (const char *const hostName)
 Open a CAN channel to a remote CAN-ETH gateway. More...
 
int canEthInstallRecvCallBack (CanHandle hdl, void(*func)(CanHandle hdl))
 Install a receive notification handler. More...
 
void canEthClose (CanHandle hdl)
 Close a CAN receive channel. More...
 
int canEthRecv (CanHandle hdl, CanMsg *msg)
 Retrieves a CAN message from the receive buffer. More...
 
int canEthSendMsg (CanHandle hdl, const CanMsg *const msg)
 Send a CAN message. More...
 

Detailed Description

This module documents the available CAN-ETH API functions.

Function Documentation

◆ canEthInit()

int canEthInit ( void  )

Initialises the CAN-ETH Ethernet interface.

A background receive thread is created and started.

Returns
CANETH_SUCCESS or a negative error code

◆ canEthShutdown()

void canEthShutdown ( void  )

Shutdown the CAN-ETH Ethernet interface.

The background receive thread is terminated and all CAN channels closed.

◆ canEthOpen()

CanHandle canEthOpen ( const char *const  hostName)

Open a CAN channel to a remote CAN-ETH gateway.

Parameters
hostNameString with IP address or host name of the remote CAN-ETH gateway.
Returns
Handle to CAN channel or negative error code

◆ canEthInstallRecvCallBack()

int canEthInstallRecvCallBack ( CanHandle  hdl,
void(*)(CanHandle hdl)  func 
)

Install a receive notification handler.

Must be called after canEthOpen

Parameters
hdlHandle to identify CAN channel
funcPointer to callback function
Returns
CANETH_SUCCESS or a negative error code

◆ canEthClose()

void canEthClose ( CanHandle  hdl)

Close a CAN receive channel.

Parameters
hdlHandle to identify CAN channel

◆ canEthRecv()

int canEthRecv ( CanHandle  hdl,
CanMsg msg 
)

Retrieves a CAN message from the receive buffer.

If no messages if available, CANETH_NO_MSG is returned.

Parameters
hdlHandle to identify CAN channel
msgPointer to container for received CAN message
Returns
CANETH_SUCCESS if OK or CANETH_NO_MSG if no message received.

References CanMsg::data, CanMsg::ext, CanMsg::id, CanMsg::len, and CanMsg::rtr.

◆ canEthSendMsg()

int canEthSendMsg ( CanHandle  hdl,
const CanMsg *const  msg 
)

Send a CAN message.

Parameters
hdlHandle to identify CAN channel
msgPointer to CAN message to be sent
Returns
CANETH_SUCCESS if sent

References CanMsg::data, CanMsg::ext, CanMsg::id, CanMsg::len, and CanMsg::rtr.