|
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. | |
| virtual | ~TTYSession () |
Public Member Functions inherited from ost::Thread | |
| 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. | |
| Thread (int pri=0, size_t stack=0) | |
| When a thread object is contructed, a new thread of execution context is created. | |
| Thread (const Thread &th) | |
| A thread of execution can also be specified by cloning an existing thread. | |
| virtual | ~Thread () |
| The thread destructor should clear up any resources that have been allocated by the thread. | |
| int | start (Semaphore *start=0) |
| When a new thread is created, it does not begin immediate execution. | |
| int | detach (Semaphore *start=0) |
| Start a new thread as "detached". | |
| Thread * | getParent (void) |
| Gets the pointer to the Thread class which created the current thread object. | |
| void | suspend (void) |
| Suspends execution of the selected thread. | |
| void | resume (void) |
| Resumes execution of the selected thread. | |
| Cancel | getCancel (void) |
| Used to retrieve the cancellation mode in effect for the selected thread. | |
| bool | isRunning (void) const |
| Verifies if the thread is still running or has already been terminated but not yet deleted. | |
| bool | isDetached (void) const |
| Check if this thread is detached. | |
| void | join (void) |
| Blocking call which unlocks when thread terminates. | |
| bool | isThread (void) const |
| Tests to see if the current execution context is the same as the specified thread object. | |
| cctid_t | getId (void) const |
| Get system thread numeric identifier. | |
| const char * | getName (void) const |
| Get the name string for this thread, to use in debug messages. | |
Public Member Functions inherited from ost::TTYStream | |
| TTYStream (const char *filename, timeout_t to=0) | |
| Create and open a tty serial port. | |
| virtual | ~TTYStream () |
| End the tty stream and cleanup. | |
| void | setTimeout (timeout_t to) |
| Set the timeout control. | |
| void | interactive (bool flag) |
| Set tty mode to buffered or "interactive". | |
| int | sync (void) |
| Flushes the stream input and out buffers, writes pending output. | |
| bool | isPending (Pending pend, timeout_t timeout=TIMEOUT_INF) |
| Get the status of pending operations. | |
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. | |
| Serial & | operator= (const Serial &from) |
| Serial ports may also be duplecated by the assignment operator. | |
| Error | setSpeed (unsigned long speed) |
| Set serial port speed for both input and output. | |
| Error | setCharBits (int bits) |
| Set character size. | |
| Error | setParity (Parity parity) |
| Set parity mode. | |
| Error | setStopBits (int bits) |
| Set number of stop bits. | |
| Error | setFlowControl (Flow flow) |
| Set flow control. | |
| void | toggleDTR (timeout_t millisec) |
| Set the DTR mode off momentarily. | |
| void | sendBreak (void) |
| Send the "break" signal. | |
| Error | getErrorNumber (void) |
| Often used by a "catch" to fetch the last error of a thrown serial. | |
| char * | getErrorString (void) |
| Often used by a "catch" to fetch the user set error string of a thrown serial. | |
| int | getBufferSize (void) |
| Get the "buffer" size for buffered operations. | |
Additional Inherited Members | |
Public Types inherited from ost::Thread | |
| 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. | |
| typedef enum ost::Thread::Cancel | Cancel |
| How work cancellation. | |
| typedef enum ost::Thread::Suspend | Suspend |
| How work suspend. | |
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 |
Static Public Member Functions inherited from ost::Thread | |
| static Thread * | get (void) |
| static void | setStack (size_t size=0) |
| Set base stack limit before manual stack sizes have effect. | |
| static void | sleep (timeout_t msec) |
| A thread-safe sleep call. | |
| static void | yield (void) |
| Yields the current thread's CPU time slice to allow another thread to begin immediate execution. | |
| static Throw | getException (void) |
| Get exception mode of the current thread. | |
| static void | setException (Throw mode) |
| Set exception mode of the current thread. | |
| 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. | |
| static void | exitCancel (Cancel cancel) |
| This is used to restore a cancel block. | |
Protected Member Functions inherited from ost::Thread | |
| void | setName (const char *text) |
| Set the name of the current thread. | |
| virtual void | run (void)=0 |
| All threads execute by deriving the Run method of Thread. | |
| virtual void | final (void) |
| A thread that is self terminating, either by invoking exit() or leaving it's run(), will have this method called. | |
| virtual void | initial (void) |
| The initial method is called by a newly created thread when it starts execution. | |
| 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(). | |
| virtual void | notify (Thread *) |
| When a thread terminates, it now sends a notification message to the parent thread which created it. | |
| void | exit (void) |
| Used to properly exit from a Thread derived run() or initial() method. | |
| void | sync (void) |
| Used to wait for a join or cancel, in place of explicit exit. | |
| bool | testCancel (void) |
| test a cancellation point for deferred thread cancellation. | |
| void | setCancel (Cancel mode) |
| Sets thread cancellation mode. | |
| void | setSuspend (Suspend mode) |
| Sets the thread's ability to be suspended from execution. | |
| void | terminate (void) |
| Used by another thread to terminate the current thread. | |
| void | clrParent (void) |
| clear parent thread relationship. | |
Protected Member Functions inherited from ost::TTYStream | |
| TTYStream () | |
| This constructor is used to derive "ttystream", a more C++ style version of the TTYStream class. | |
| void | allocate (void) |
| Used to allocate the buffer space needed for iostream operations. | |
| void | endStream (void) |
| Used to terminate the buffer space and clean up the tty connection. | |
| int | underflow (void) |
| This streambuf method is used to load the input buffer through the established tty serial port. | |
| int | uflow (void) |
| This streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode. | |
| int | overflow (int ch) |
| This streambuf method is used to write the output buffer through the established tty port. | |
Protected Member Functions inherited from ost::Serial | |
| void | open (const char *fname) |
| Opens the serial device. | |
| void | close (void) |
| Closes the serial device. | |
| virtual int | aRead (char *Data, const int Length) |
| Reads from serial device. | |
| virtual int | aWrite (const char *Data, const int Length) |
| Writes to serial device. | |
| Error | error (Error error, char *errstr=NULL) |
| This service is used to throw all serial errors which usually occur during the serial constructor. | |
| void | error (char *err) |
| This service is used to thow application defined serial errors where the application specific error code is a string. | |
| void | setError (bool enable) |
| This method is used to turn the error handler on or off for "throwing" execptions by manipulating the thrown flag. | |
| int | setPacketInput (int size, unsigned char btimer=0) |
| Set packet read mode and "size" of packet read buffer. | |
| 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. | |
| void | restore (void) |
| Restore serial device to the original settings at time of open. | |
| void | flushInput (void) |
| Used to flush the input waiting queue. | |
| void | flushOutput (void) |
| Used to flush any pending output data. | |
| void | waitOutput (void) |
| Used to wait until all output has been sent. | |
| void | endSerial (void) |
| Used as the default destructor for ending serial I/O services. | |
| void | initConfig (void) |
| Used to initialize a newly opened serial file handle. | |
| Serial () | |
| This allows later ttystream class to open and close a serial device. | |
| Serial (const char *name) | |
| A serial object may be constructed from a named file on the file system. | |
Protected Attributes inherited from ost::TTYStream | |
| char * | gbuf |
| char * | pbuf |
| timeout_t | timeout |
Protected Attributes inherited from ost::Serial | |
| 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 |