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.