available()
説明
CAN FIFOには読み取り可能な値を含むか。
語法
CAN.available()
パラメータ
無
戻り値
FIFOに読み取り可能な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
- requestFrom()
- read()
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.
