linux

canRead

Syntax


#include <canlib.h>
canStatus canRead(
    int handle, long* id, 
    void* msg, unsigned int* dlc, 
    unsigned int* flag, DWORD* time);

Description

Reads a message from the receive buffer. If no message is available, the function returns immediately with return code canERR_NOMSG.

Input Parameters

handle
A handle to an open circuit.
Input/Output Parameters

id
Pointer to a buffer which receives the CAN identifier. This buffer will only get the identifier. To determine whether this identifier was standard (11-bit) or extended (29-bit), and/or whether is was remote or not, examine the contents of the flag argument.
msg
Pointer to the buffer which receives the message data. This buffer must be large enough (i.e. 8 bytes.) Only the message data is copied; the rest of the buffer is left as-is.
dlc
Pointer to a buffer which receives the message length.
flag
Pointer to a buffer which receives the message flags, which is a combination of the canMSG_xxx and canMSGERR_xxx values.
time
Pointer to a buffer which receives the message time stamp.
Return Value

canOK (zero) if a message was read.
canERR_NOMSG (negative) if there was no message available.
canERR_xxx (negative) if failure.

Notes
Related Topics

canReadWait

An example.