> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/arduino-language/functions/communication/readbytes.md).

# Serial.readBytes(buffer, length)

从串口读字符到一个缓冲区.如果预设的长度读取完毕或者时间到了 (参见 Serial.setTimeout())，函数将终止.

### 参数

| 参数名    | 描述                          |
| ------ | --------------------------- |
| buffer | 用来存储字节（char\[]或byte\[]）的缓冲区 |
| length | 读取的字节数（int）                 |

### 返回

| 参数名    | 描述                            |
| ------ | ----------------------------- |
| number | 返回放置在缓冲区的字符数。返回0意味着没有发现有效的数据。 |
