bayonne-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bayonne-devel] TTYStream::isPending() VS istream::peek() - 0:1


From: Tarmo Kuuse
Subject: [Bayonne-devel] TTYStream::isPending() VS istream::peek() - 0:1
Date: Thu, 06 Apr 2006 15:44:29 +0300
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Hi!

I am using the GNU Common C++ library (version 1.3.25) class TTYSession to implement a simple XModem program. A very elegant abstraction, I must admit.

During an XModem session I wish to peek at a character in the incoming byte stream. To do that, I call the method peek(), inherited from std::istream.

However, this breaks the method TTYStream::isPending().

If the serial device buffer contains 1 unread byte, isPending() returns "true"; However, if peek() is called before isPending(), isPending returns "false" - regardless of the fact that unread data is in the buffer.

To me, this behaviour seems rather undesirable. I wish to check (in different functions) if data is available for reading with isPending() and occasionally take a peek at that data without actually reading it.

I took a quick look at your code starting at "serial.c:988". You use poll() to check for incoming bytes. The istream::peek() method probably marks the byte as "read" and poll() does not detect it.

Is it possible to either override istream::peek() or rewrite TTYStream::isPending() so that it becomes possible to peek at data before doing isPending() check on it?

--
Best Regards,
Tarmo Kuuse

Software developer
Oskando Ltd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]