read()
説明
讀取 CAN FIFO 中的資料。
語法
CAN.read()
パラメータ
無
戻り値
もし FIFO からではないとするならば, 1 byteを送信した值であるが,しかしながら -1となる。
例
#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()
- available()
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.
