GNU CommonC++
Public Member Functions | List of all members
ost::ttystream Class Reference

A more natural C++ "ttystream" class for use by non-threaded applications. More...

#include <serial.h>

Inheritance diagram for ost::ttystream:
ost::TTYStream ost::Serial

Public Member Functions

 ttystream ()
 Construct an unopened "ttystream" object. More...
 
 ttystream (const char *name)
 Construct and "open" a tty stream object. More...
 
void open (const char *name)
 Open method for a tty stream. More...
 
void close (void)
 Close method for a tty stream. More...
 
bool operator! ()
 Test to see if stream is opened. More...
 
- Public Member Functions inherited from ost::TTYStream
 TTYStream (const char *filename, timeout_t to=0)
 Create and open a tty serial port. More...
 
virtual ~TTYStream ()
 End the tty stream and cleanup. More...
 
void setTimeout (timeout_t to)
 Set the timeout control. More...
 
void interactive (bool flag)
 Set tty mode to buffered or "interactive". More...
 
int sync (void)
 Flushes the stream input and out buffers, writes pending output. More...
 
bool isPending (Pending pend, timeout_t timeout=TIMEOUT_INF)
 Get the status of pending operations. More...
 
- Public Member Functions inherited from ost::Serial
virtual ~Serial ()
 The serial base class may be "thrown" as a result on an error, and the "catcher" may then choose to destory the object. More...
 
Serialoperator= (const Serial &from)
 Serial ports may also be duplecated by the assignment operator. More...
 
Error setSpeed (unsigned long speed)
 Set serial port speed for both input and output. More...
 
Error setCharBits (int bits)
 Set character size. More...
 
Error setParity (Parity parity)
 Set parity mode. More...
 
Error setStopBits (int bits)
 Set number of stop bits. More...
 
Error setFlowControl (Flow flow)
 Set flow control. More...
 
void toggleDTR (timeout_t millisec)
 Set the DTR mode off momentarily. More...
 
void sendBreak (void)
 Send the "break" signal. More...
 
Error getErrorNumber (void)
 Often used by a "catch" to fetch the last error of a thrown serial. More...
 
char * getErrorString (void)
 Often used by a "catch" to fetch the user set error string of a thrown serial. More...
 
int getBufferSize (void)
 Get the "buffer" size for buffered operations. More...
 

Additional Inherited Members

- Public Types inherited from ost::Serial
enum  Error {
  errSuccess = 0, errOpenNoTty, errOpenFailed, errSpeedInvalid,
  errFlowInvalid, errParityInvalid, errCharsizeInvalid, errStopbitsInvalid,
  errOptionInvalid, errResourceFailure, errOutput, errInput,
  errTimeout, errExtended
}
 
enum  Flow { flowNone, flowSoft, flowHard, flowBoth }
 
enum  Parity { parityNone, parityOdd, parityEven }
 
enum  Pending { pendingInput, pendingOutput, pendingError }
 
typedef enum Error Error
 
typedef enum Flow Flow
 
typedef enum Parity Parity
 
typedef enum Pending Pending
 
- Protected Member Functions inherited from ost::TTYStream
 TTYStream ()
 This constructor is used to derive "ttystream", a more C++ style version of the TTYStream class. More...
 
void allocate (void)
 Used to allocate the buffer space needed for iostream operations. More...
 
void endStream (void)
 Used to terminate the buffer space and clean up the tty connection. More...
 
int underflow (void)
 This streambuf method is used to load the input buffer through the established tty serial port. More...
 
int uflow (void)
 This streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode. More...
 
int overflow (int ch)
 This streambuf method is used to write the output buffer through the established tty port. More...
 
- Protected Member Functions inherited from ost::Serial
void open (const char *fname)
 Opens the serial device. More...
 
void close (void)
 Closes the serial device. More...
 
virtual int aRead (char *Data, const int Length)
 Reads from serial device. More...
 
virtual int aWrite (const char *Data, const int Length)
 Writes to serial device. More...
 
Error error (Error error, char *errstr=NULL)
 This service is used to throw all serial errors which usually occur during the serial constructor. More...
 
void error (char *err)
 This service is used to thow application defined serial errors where the application specific error code is a string. More...
 
void setError (bool enable)
 This method is used to turn the error handler on or off for "throwing" execptions by manipulating the thrown flag. More...
 
int setPacketInput (int size, unsigned char btimer=0)
 Set packet read mode and "size" of packet read buffer. More...
 
int setLineInput (char newline=13, char nl1=0)
 Set "line buffering" read mode and specifies the newline character to be used in seperating line records. More...
 
void restore (void)
 Restore serial device to the original settings at time of open. More...
 
void flushInput (void)
 Used to flush the input waiting queue. More...
 
void flushOutput (void)
 Used to flush any pending output data. More...
 
void waitOutput (void)
 Used to wait until all output has been sent. More...
 
void endSerial (void)
 Used as the default destructor for ending serial I/O services. More...
 
void initConfig (void)
 Used to initialize a newly opened serial file handle. More...
 
 Serial ()
 This allows later ttystream class to open and close a serial device. More...
 
 Serial (const char *name)
 A serial object may be constructed from a named file on the file system. More...
 
- Protected Attributes inherited from ost::TTYStream
char * gbuf
 
char * pbuf
 
timeout_t timeout
 
- Protected Attributes inherited from ost::Serial
HANDLE dev
 
int bufsize
 

Detailed Description

A more natural C++ "ttystream" class for use by non-threaded applications.

This class behaves a lot more like fstream and similar classes.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m C++ "fstream" style ttystream class.

Constructor & Destructor Documentation

ost::ttystream::ttystream ( )

Construct an unopened "ttystream" object.

ost::ttystream::ttystream ( const char *  name)

Construct and "open" a tty stream object.

A filename in the form "device:options[,options]" may be used to pass device options as part of the open.

Parameters
nameof file and serial options.

Member Function Documentation

void ost::ttystream::close ( void  )

Close method for a tty stream.

void ost::ttystream::open ( const char *  name)

Open method for a tty stream.

Parameters
namefilename to open.
bool ost::ttystream::operator! ( void  )
inline

Test to see if stream is opened.


The documentation for this class was generated from the following file: