requestFrom()

説明

CAN bus 上のデータを取得する。

語法


CAN.requestFrom()

パラメータ

戻り値

取得したbyte 数

#include <CANBus.h>
unsigned char ch;
void setup() {
    Serial.begin(115200);
    CAN.begin(CAN_500KBPS);
}

void loop() {
    if (CAN.requestFrom() > 0)         // データを取得できているか検査する
    {
        while (CAN.available() > 0)    // FIFO 內に読み取り可能なデータが取得できているか検査す
        {
            ch = CAN.read();           // FIFO内のデータ読み取り
            Serial.print(ch);          // データ値出力
            Serial.print("\t");
        }
        Serial.println();
    }
}

See also

available()
read()


Libraries Reference Home

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.