readBytesUntil()

描述

readBytesUntil()可以把串流收到的字元放到一個指定的陣列中。這個函式會直到偵測到結尾字符、符合指定的長度或超過指定時間後停止 (時間的設定可參考 Serial.setTimeout())。

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

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

語法


stream.readBytesUntil(character, buffer, length)

參數

stream : 一個類別的實例,這個類別是繼承於 Stream
character : 要尋找的結尾字符 (char 型別)
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.