Im writing a program which reads and writes to serial. I was 开发者_Go百科wondering, is there a way to peek the next value from a tty device such as /dev/ttyS0 without removing it from the queue. I have looked for documentation or even source code for this module and have been so far, unable to find it. If anyone knows where it is, or which ioctls are available, please let me know.
Using a combination of getc
and ungetc
will allow you to peek a single byte.
If you need more than one byte, you'll need to buffer it manually.
精彩评论