peek()

描述

从串流收到并放在缓冲区内的资料中,取得下次呼叫 read() 会得到的值。呼叫这个函式并不会减少缓冲区内的资料总数,换句话说,透过 peek() 成功取得值后,下次用 read() 也会得到相同的值。

这个函式是 Stream 类别的一部分,它可以被任何继承它的类别呼叫 (例如:Wire、Serial 等等) 。

语法


stream.peek()

参数

stream : 一个类别的实例,这个类别是继承于 Stream

回传

下一个可用的 byte (假如缓冲区内没有值,则回传 -1) int 型别

See also

Stream
available()
read()


语法参考主页面

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.