Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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_INT16S CanBusRead(CPU_INT16S   busId,
                      void        *buffer,
                      CPU_INT16U   size);

Parameter

Meaning

busId

Unique bus identifier

buffer

Pointer to CAN frame of type CANFRM

size

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.