开发者

Is there a way to peek a value from a tty device

开发者 https://www.devze.com 2023-02-20 10:11 出处:网络
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 ha

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号