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.