我想找...

搜尋

分享

目錄

CAN.requestFrom()

[CANBus]

描述

Receive data from CAN bus.

語法

CAN.requestFrom()

參數

None

回傳

Number of byte received

範例

#include <CANBus.h>
unsigned char ch;
void setup() {
    Serial.begin(115200);
    CAN.begin(CAN_500KBPS);
}
 
void loop() {
    if (CAN.requestFrom() > 0)         // Check to see whether data received.
    {
        while (CAN.available() > 0)    // Check FIFO to see whether there are data to retrieve.
        {
            ch = CAN.read();           // Read data from FIFO.
            Serial.print(ch);          // Output data value.
            Serial.print("\t");
        }
        Serial.println();
    }
}

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

返回頂端