Im writing a program which reads and writes to serial. I was 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.
Share
Using a combination of
getcandungetcwill allow you to peek a single byte.If you need more than one byte, you’ll need to buffer it manually.