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.
