class TTYStream

streamable tty serial I/O class. More...

Full nameost::TTYStream
Definition#include <serial.h>
Inheritsost::Serial [public ], std::iostream (unknown) [public ], std::streambuf (unknown) [public ]
Inherited byTTYSession, ttystream
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Protected Members


Detailed Description

TTY streams are used to represent serial connections that are fully "streamable" objects using C++ stream classes and friends.

The first application relevant serial I/O class is the TTYStream class. TTYStream offers a linearly buffered "streaming" I/O session with the serial device. Furthermore, traditional C++ "stream" operators (<< and >>) may be used with the serial device. A more "true" to ANSI C++ library format "ttystream" is also available, and this supports an "open" method in which one can pass initial serial device parameters immediately following the device name in a single string, as in "/dev/tty3a:9600,7,e,1", as an example.

The TTYSession aggragates a TTYStream and a Common C++ Thread which is assumed to be the execution context that will be used to perform actual I/O operations. This class is very anagolous to TCPSession.

char * gbuf

gbuf

[protected]

char * pbuf

pbuf

[protected]

timeout_t timeout

timeout

[protected]

 TTYStream ()

TTYStream

[protected]

This constructor is used to derive "ttystream", a more C++ style version of the TTYStream class.

void  Allocate (void)

Allocate

[protected]

Used to allocate the buffer space needed for iostream operations. This is based on MAX_INPUT.

void  endStream (void)

endStream

[protected]

Used to terminate the buffer space and clean up the tty connection. This function is called by the destructor.

int  underflow (void)

underflow

[protected]

This streambuf method is used to load the input buffer through the established tty serial port.

Returns: char from get buffer, EOF also possible.

int  uflow (void)

uflow

[protected]

This streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode. Also this method will handle proper use of buffers if not in interative mode.

Returns: char from tty serial port, EOF also possible.

int  overflow (int ch)

overflow

[protected]

This streambuf method is used to write the output buffer through the established tty port.

Parameters:
charto push through.

Returns: char pushed through.

 TTYStream (const char *filename)

TTYStream

Create and ipen a tty serial port.

Parameters:
charname of device to open.

 ~TTYStream ()

~TTYStream

[virtual]

End the tty stream and cleanup.

inline void  setTimeout (timeout_t to)

setTimeout

Set the timeout control.

Parameters:
timeoutto use.

void  Interactive (bool flag)

Interactive

Set tty mode to buffered or "interactive". When interactive, all streamed I/O is directly sent to the serial port immediately.

Parameters:
boolset to true to make interactive.

int  sync (void)

sync

Flushes the stream input and out buffers, writes pending output.

Returns: 0 on success.

bool  isPending (siopend_t pend, timeout_t timeout = TIMEOUT_INF)

isPending

Get the status of pending operations. This can be used to examine if input or output is waiting, or if an error has occured on the serial device. If read buffer contains data then input is ready and if write buffer contains data it is first flushed then checked.

Parameters:
readycheck to perform.
timeoutin milliseconds.

Returns: true if ready, false if timeout.

Reimplemented from Serial.