www.beck-ipc.com

@CHIP-RTOS C Library V2.06 - CAN API


CAN_Recv

Receive a CAN message, with optional time-out.

int CAN_Recv (  unsigned int port_idx,

CAN_MSG far *msg,
int timeout );

Parameters

port_idx

CAN port specifier:   CAN0_PORT = 0, or CAN1_PORT = 1

msg

Output Parameter:   Pointer to a CAN_MSG data structure were this API will output the next CAN message if one is available.

timeout

Time-out
    Negative value:   No wait, return immediately
    Zero:   Wait forever for a CAN message
    Positive value:   Maximum milliseconds to wait for a CAN message

Return Value

Error code -
CAN_EC_SUCCESS = 0:   Success, new message is in data structure referenced by msg pointer.
CAN_EC_INVALID_PARAMS = -1:   port_idx or msg pointer invalid.
CAN_EC_PORT_NOT_OPENED = -3:   Port has not been opened. CAN_EC_TIMEOUT = -6:   Time period expired and still no message available.

Comments

This function is used to pick up the next received CAN message from the receiver FIFO queue.   The message is removed from the input queue upon transfer here to the user.

The timeout parameter allows the caller to optionally sleep on the receiver a specified number of milliseconds until a received CAN message becomes available.

Note that if the CAN port is closed, the CAN_Close_Port API strobes the event bits to assure that a program thread which is sleeping on the receiver within this API will return (and not be left hanging on a no longer existant event group).

Inside this API the interrupts are masked for a short period and then re-enabled.   This function is reentrant.

Important Note:

    No CAN messages will be received until the port's receiver filters have been enabled for reception using the CAN_Rx_Filters API.   Following a system reset, the CAN receiver filters are initialized to reject all incoming CAN messages by default.

See Also

RTOS API

This library function uses a dynamic link to reach the service offered by RTOS software interrupt.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3
    n/an/an/aV0.90

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.01

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document