Serial.readBytes()

描述

Serial.readBytes() 可以把收到 (在缓冲区内) 的字元放到指定的阵列中,直到符合指定的长度或是超过一段时间 (时间的设定请参考 Serial.setTimeout()).

Serial.readBytes() 会回传在缓冲区中的字元总数。假如缓冲区内没有可用的值时,将回传 0。

Serial.readBytes() 是继承于 Stream 类别。

语法


Serial.readBytes(buffer, length)

参数

buffer: 储存资料的阵列 (char[] or byte[] 型别)
length: 要读取的 byte 总数 (int 型别)

回传

byte

See also

Stream
Stream.readBytes()


语法参考主页面

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.