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.