checkReceive()

Desription

Check CAN bus’ FIFO buffer to see whether there are data to read.(This function is created referencing the CAN Bus library from Seeed Studio. Note: This function must be used with the readMsgBuf() function.

Syntax


CAN.checkReceive(void)

Parameters

None

Returns

CAN_MSGAVAIL:Indicates there are data in FIFO buffer to be read.
CAN_NOMSG:Indicates there is no data in the FIFO buffer.

Examples

#include <CANBus.h>
unsigned char len = 0;
unsigned char buf[8];

void setup() {
    Serial.begin(115200);
    CAN.begin(CAN_500KBPS);
}

void loop() {
    if(CAN_MSGAVAIL == CAN.checkReceive())            // Check to see whether data is received.
    {
        CAN.readMsgBuf(&len, buf);    // Read data

        for(int i = 0; i<len; i++)    // Output data value
        {
            Serial.print(buf[i]);Serial.print("\t");
        }
        Serial.println();
    }
}

See also

readMsgBuf()


函式庫參考主頁面

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.