Description
readMsgBuf()
– reads and removes a message from the receive buffer
Syntax
MCAN0.readMsgBuf( t_canMesgToRecv )
Parameters
CANMessage t_canMesgToRecv– CAN message object to be filled with the new message from the receive buffer
Returns
uint8_t:
CAN_OK – OK. Message could be fetched
CAN_NOMSG – Error. No message available in the rx buffer
Example Code
The following example receives messages on the CAN bus (MCAN0).
void setup()
{
while(!Serial);
Serial.println("Simple example receiving CAN messages");
}
void loop()
{
if( MCAN0.checkReceive() )
{
CANMessage t_canMesgToRecv;
if(MCAN0.readMsgBuf( t_canMesgToRecv ) == CAN_OK)
Serial.println(t_canMesgToRecv.toString());
}
}
Notes and Warnings
Examples can be found in the Arduino IDE menu:
File -> Examples -> DICE -> CAN Bus ->
See also
Find more details about the the CAN bus of dice devices
checkReceive()
sendMsgBuf()
defines
SAMC21_CAN – Library
CAN operation background
users manual
BOOTLOADER SETTINGS – Library