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
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.
