Data Structures | Typedefs | Functions

canethlib.h File Reference

CAN API for proconX CAN-ETH gateway - Header file. More...

Data Structures

struct  CANFRAME
 CAN message structure. More...

Typedefs

typedef int CanHandle
 Handle to a CAN connection. Returned by canEthOpen().

Functions

int canEthInit (void)
 Initialises the CAN-ETH Ethernet interface.
void canEthShutdown (void)
 Shutdown the CAN-ETH Ethernet interface.
CanHandle canEthOpen (const char *const hostName)
 Open a CAN channel to a remote CAN-ETH gateway.
void canEthClose (CanHandle handle)
 Close a CAN receive channel.
int canEthRecv (CanHandle handle, CANFRAME *msg)
 Retrieves a CAN message from the receive buffer.
int canEthSendMsg (CanHandle handle, const CANFRAME *const msg)
 Send a CAN message.

Error and Return Codes



#define CANETH_SUCCESS   0
 Operation was successful.
#define CANETH_ILLEGAL_ARGUMENT_ERROR   (-1)
 Illegal argument error.
#define CANETH_NO_MSG   (-2)
 No messages.
#define CANETH_INVALID_HOST   (-3)
 Invalid IP address or hostname.
#define CANETH_MAX_OPEN   (-4)
 Maximum number of open connections exceeded.
#define CANETH_SOCKET_LIB_ERROR   (-5)
 Socket library error.
#define CANETH_PORT_ALREADY_BOUND   (-6)
 UDP port already bound.
#define CANETH_SOCKET_FAILED   (-7)
 Creation of socket failed.
#define CANETH_CREATE_THREAD_FAILED   (-8)
 Creation of background thread failed.

Detailed Description

CAN API for proconX CAN-ETH gateway - Header file.


Define Documentation

#define CANETH_SUCCESS   0

Operation was successful.

This return codes indicates no error.

#define CANETH_ILLEGAL_ARGUMENT_ERROR   (-1)

Illegal argument error.

A parameter passed to the function returning this error code is invalid or out of range.

#define CANETH_NO_MSG   (-2)

No messages.

The receive buffer does not contain any messages.

#define CANETH_INVALID_HOST   (-3)

Invalid IP address or hostname.

The IP address or hostname provided is invalid or cannot be reached.

#define CANETH_MAX_OPEN   (-4)

Maximum number of open connections exceeded.

Maximum number of usable CAN connections were exceeded.

#define CANETH_SOCKET_LIB_ERROR   (-5)

Socket library error.

The TCP/IP socket library (e.g. WINSOCK) could not be loaded or the DLL is missing or not installed.

#define CANETH_PORT_ALREADY_BOUND   (-6)

UDP port already bound.

Indicates that the specified UDP port cannot be bound. The port might already be taken by another application or hasn't been released yet by the TCP/IP stack for re-use.

#define CANETH_SOCKET_FAILED   (-7)

Creation of socket failed.

The creation of a UDP socket failed.

#define CANETH_CREATE_THREAD_FAILED   (-8)

Creation of background thread failed.

The system could not create the background receive thread.


Function Documentation

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
void canEthShutdown ( void   ) 

Shutdown the CAN-ETH Ethernet interface.

The background receive thread is terminated.

CanHandle canEthOpen ( const char *const   hostName  ) 

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

Parameters:
hostName String with IP address or host name of the remote CAN-ETH gateway.
Returns:
Handle to CAN channel or negative error code
void canEthClose ( CanHandle  handle  ) 

Close a CAN receive channel.

Parameters:
handle Handle to identify CAN channel.

References MAX_CAN_GATEWAYS.

int canEthRecv ( CanHandle  handle,
CANFRAME msg 
)

Retrieves a CAN message from the receive buffer.

If no messages if available, CANETH_NO_MSG is returned.

Parameters:
handle Handle to identify CAN channel.
msg Pointer to container for received CAN message
Returns:
CANETH_SUCCESS if OK or CANETH_NO_MSG if no message received.

References MAX_CAN_GATEWAYS.

int canEthSendMsg ( CanHandle  handle,
const CANFRAME *const   msg 
)

Send a CAN message.

Parameters:
handle Handle to identify CAN channel.
msg Pointer to CAN message to be sent
Returns:
CANETH_SUCCESS if sent

References MAX_CAN_GATEWAYS.


CAN-ETH C Library
Draft Version