Description
This function is called by the application to obtain a frame from the opened CAN bus. The function will wait for a frame to be received on the CAN bus or until the configured timeout is reached.
Prototype
CPU_INT16SINT16S CanBusRead(CPU_INT16SINT16S busId,
void *buffer,
CPU_INT16UINT16U size);
Parameter | Meaning |
---|---|
| Unique bus identifier |
| Pointer to CAN frame of type CANFRM |
| Size of buffer in bytes (must be equal to sizeof(CANFRM)) |
Note
...
A timeout is not handled as an error, therefore the return value in this case is 0.
Return Value
One of the error codes CAN_ERR_BUSID
, CAN_ERR_NULLPTR
, CAN_ERR_FRMSIZE
or CAN_ERR_OSFREE
if an error is detected. Otherwise the number of bytes of a CAN frame is returned.