GNU CommonC++
|
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. More...
#include <serial.h>
Public Member Functions | |
TTYSession (const char *name, int pri=0, int stack=0) | |
Create TTY stream that will be managed by it's own thread. More... | |
virtual | ~TTYSession () |
![]() | |
Thread (bool isMain) | |
This is actually a special constructor that is used to create a thread "object" for the current execution context when that context is not created via an instance of a derived Thread object itself. More... | |
Thread (int pri=0, size_t stack=0) | |
When a thread object is contructed, a new thread of execution context is created. More... | |
Thread (const Thread &th) | |
A thread of execution can also be specified by cloning an existing thread. More... | |
virtual | ~Thread () |
The thread destructor should clear up any resources that have been allocated by the thread. More... | |
int | start (Semaphore *start=0) |
When a new thread is created, it does not begin immediate execution. More... | |
int | detach (Semaphore *start=0) |
Start a new thread as "detached". More... | |
Thread * | getParent (void) |
Gets the pointer to the Thread class which created the current thread object. More... | |
void | suspend (void) |
Suspends execution of the selected thread. More... | |
void | resume (void) |
Resumes execution of the selected thread. More... | |
Cancel | getCancel (void) |
Used to retrieve the cancellation mode in effect for the selected thread. More... | |
bool | isRunning (void) const |
Verifies if the thread is still running or has already been terminated but not yet deleted. More... | |
bool | isDetached (void) const |
Check if this thread is detached. More... | |
void | join (void) |
Blocking call which unlocks when thread terminates. More... | |
bool | isThread (void) const |
Tests to see if the current execution context is the same as the specified thread object. More... | |
cctid_t | getId (void) const |
Get system thread numeric identifier. More... | |
const char * | getName (void) const |
Get the name string for this thread, to use in debug messages. More... | |
![]() | |
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... | |
![]() | |
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... | |
Serial & | operator= (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 | |
![]() | |
enum | Throw { throwNothing, throwObject, throwException } |
How to raise error. More... | |
enum | Cancel { cancelInitial =0, cancelDeferred =1, cancelImmediate, cancelDisabled, cancelManual, cancelDefault =cancelDeferred } |
How work cancellation. More... | |
enum | Suspend { suspendEnable, suspendDisable } |
How work suspend. More... | |
typedef enum ost::Thread::Throw | Throw |
How to raise error. More... | |
typedef enum ost::Thread::Cancel | Cancel |
How work cancellation. More... | |
typedef enum ost::Thread::Suspend | Suspend |
How work suspend. More... | |
![]() | |
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 |
![]() | |
static Thread * | get (void) |
static void | setStack (size_t size=0) |
Set base stack limit before manual stack sizes have effect. More... | |
static void | sleep (timeout_t msec) |
A thread-safe sleep call. More... | |
static void | yield (void) |
Yields the current thread's CPU time slice to allow another thread to begin immediate execution. More... | |
static Throw | getException (void) |
Get exception mode of the current thread. More... | |
static void | setException (Throw mode) |
Set exception mode of the current thread. More... | |
static Cancel | enterCancel (void) |
This is used to help build wrapper functions in libraries around system calls that should behave as cancellation points but don't. More... | |
static void | exitCancel (Cancel cancel) |
This is used to restore a cancel block. More... | |
![]() | |
void | setName (const char *text) |
Set the name of the current thread. More... | |
virtual void | run (void)=0 |
All threads execute by deriving the Run method of Thread. More... | |
virtual void | final (void) |
A thread that is self terminating, either by invoking exit() or leaving it's run(), will have this method called. More... | |
virtual void | initial (void) |
The initial method is called by a newly created thread when it starts execution. More... | |
virtual void * | getExtended (void) |
Since getParent() and getThread() only refer to an object of the Thread "base" type, this virtual method can be replaced in a derived class with something that returns data specific to the derived class that can still be accessed through the pointer returned by getParent() and getThread(). More... | |
virtual void | notify (Thread *) |
When a thread terminates, it now sends a notification message to the parent thread which created it. More... | |
void | exit (void) |
Used to properly exit from a Thread derived run() or initial() method. More... | |
void | sync (void) |
Used to wait for a join or cancel, in place of explicit exit. More... | |
bool | testCancel (void) |
test a cancellation point for deferred thread cancellation. More... | |
void | setCancel (Cancel mode) |
Sets thread cancellation mode. More... | |
void | setSuspend (Suspend mode) |
Sets the thread's ability to be suspended from execution. More... | |
void | terminate (void) |
Used by another thread to terminate the current thread. More... | |
void | clrParent (void) |
clear parent thread relationship. More... | |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
char * | gbuf |
char * | pbuf |
timeout_t | timeout |
![]() | |
HANDLE | dev |
int | bufsize |
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.
This class is very anagolous to TCPSession.
ost::TTYSession::TTYSession | ( | const char * | name, |
int | pri = 0 , |
||
int | stack = 0 |
||
) |
Create TTY stream that will be managed by it's own thread.
name | of tty device to open. |
pri | execution priority. |
stack | allocation needed on some platforms. |
|
virtual |