readBytes()

描述

readBytes() 可以從串流讀取字元,然後把它們放到指定陣列中,直到符合指定的長度,或是超過一段時間 (時間的設定請參考 setTimeout())。

readBytes() 會回傳在緩衝區中的字元總數。假如緩衝取內沒有可用的值時,將回傳 0。

這個函式是 Stream 類別的一部分,它可以被任何繼承它的類別呼叫 (例如:Wire、Serial 等等) 。

語法


stream.readBytes(buffer, length)

參數

stream : 一個類別的實例,這個類別是繼承於 Stream
buffer : 儲存資料的陣列 (char[] or byte[] 型別)
length : 要讀取的 byte 總數 (int 型別)

回傳

緩衝區內的 byte 總數

See also

Stream


語法參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.