ucommon
|
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... | |
![]() | |
void | detach (void) |
void | exit (void) |
virtual void | final (void) |
void | finalize (void) |
pthread_t | getId (void) |
Get the thread id. | |
virtual void | initial (void) |
bool | isRunning (void) |
bool | isThread (void) |
void | join (void) |
void | map (void) |
virtual void | notify (Thread *thread) |
virtual void | run (void)=0 |
void | start (void) |
void | sync (void) |
void | terminate (void) |
Thread (int pri=0, size_t stack=0) | |
![]() | |
void | interactive (bool flag) |
Set tty mode to buffered or "interactive". More... | |
bool | isPending (Pending pend, timeout_t timeout=ucommon::Timer::inf) |
Get the status of pending operations. More... | |
void | setTimeout (timeout_t to) |
Set the timeout control. More... | |
int | sync (void) |
Flushes the stream input and out buffers, writes pending output. 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. | |
![]() | |
int | getBufferSize (void) |
Get the "buffer" size for buffered operations. 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... | |
Serial & | operator= (const Serial &from) |
Serial ports may also be duplecated by the assignment operator. | |
void | sendBreak (void) |
Send the "break" signal. | |
Error | setCharBits (int bits) |
Set character size. More... | |
Error | setFlowControl (Flow flow) |
Set flow control. More... | |
Error | setParity (Parity parity) |
Set parity mode. More... | |
Error | setSpeed (unsigned long speed) |
Set serial port speed for both input and output. More... | |
Error | setStopBits (int bits) |
Set number of stop bits. More... | |
void | toggleDTR (timeout_t millisec) |
Set the DTR mode off momentarily. 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... | |
Additional Inherited Members | |
![]() | |
enum | Throw { throwNothing, throwObject, throwException } |
How to raise error. | |
typedef enum ost::Thread::Throw | Throw |
How to raise error. | |
![]() | |
enum | Error { errSuccess = 0, errOpenNoTty, errOpenFailed, errSpeedInvalid, errFlowInvalid, errParityInvalid, errCharsizeInvalid, errStopbitsInvalid, errOptionInvalid, errResourceFailure, errOutput, errInput, errTimeout, errExtended } |
typedef enum Error | Error |
enum | Flow { flowNone, flowSoft, flowHard, flowBoth } |
typedef enum Flow | Flow |
enum | Parity { parityNone, parityOdd, parityEven } |
typedef enum Parity | Parity |
enum | Pending { pendingInput, pendingOutput, pendingError } |
typedef enum Pending | Pending |
![]() | |
static Thread * | get (void) |
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 void | sleep (timeout_t msec=ucommon::Timer::inf) |
static void | yield (void) |
![]() | |
enum | |
![]() | |
enum | Error { errSuccess = 0, errOpenNoTty, errOpenFailed, errSpeedInvalid, errFlowInvalid, errParityInvalid, errCharsizeInvalid, errStopbitsInvalid, errOptionInvalid, errResourceFailure, errOutput, errInput, errTimeout, errExtended } |
typedef enum Error | Error |
enum | Flow { flowNone, flowSoft, flowHard, flowBoth } |
typedef enum Flow | Flow |
enum | Parity { parityNone, parityOdd, parityEven } |
typedef enum Parity | Parity |
enum | Pending { pendingInput, pendingOutput, pendingError } |
typedef enum Pending | Pending |
![]() | |
bool | is_active (void) |
Check if running. | |
void | join (void) |
Join thread with parent. More... | |
JoinableThread (size_t size=0) | |
Create a joinable thread with a known context stack size. More... | |
virtual void | run (void)=0 |
Abstract interface for thread context run method. | |
virtual | ~JoinableThread () |
Delete child thread. More... | |
void | background (void) |
Start execution of child context as background thread. More... | |
void | start (int priority=0) |
Start execution of child context. More... | |
![]() | |
void | map (void) |
Map thread for get method. More... | |
Thread (size_t stack=0) | |
Create a thread object that will have a preset stack size. More... | |
virtual void | exit (void) |
Exit the thread context. More... | |
bool | isRunning (void) |
operator bool () | |
bool | operator! () |
void | setPriority (void) |
Set thread priority without disrupting scheduling if possible. More... | |
virtual | ~Thread () |
Destroy thread object, thread-specific data, and execution context. | |
![]() | |
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 | overflow (int ch) |
This streambuf method is used to write the output buffer through the established tty port. More... | |
TTYStream () | |
This constructor is used to derive "ttystream", a more C++ style version of the TTYStream class. | |
int | uflow (void) |
This streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode. More... | |
int | underflow (void) |
This streambuf method is used to load the input buffer through the established tty serial port. 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... | |
void | close (void) |
Closes the serial device. | |
void | endSerial (void) |
Used as the default destructor for ending serial I/O services. More... | |
Error | error (Error error, char *errstr=((void *) 0)) |
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 | flushInput (void) |
Used to flush the input waiting queue. | |
void | flushOutput (void) |
Used to flush any pending output data. | |
void | initConfig (void) |
Used to initialize a newly opened serial file handle. More... | |
void | open (const char *fname) |
Opens the serial device. More... | |
void | restore (void) |
Restore serial device to the original settings at time of open. | |
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. 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 | 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... | |
int | setPacketInput (int size, unsigned char btimer=0) |
Set packet read mode and "size" of packet read buffer. More... | |
void | waitOutput (void) |
Used to wait until all output has been sent. | |
int | getBufferSize (void) |
Get the "buffer" size for buffered operations. 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... | |
Serial & | operator= (const Serial &from) |
Serial ports may also be duplecated by the assignment operator. | |
void | sendBreak (void) |
Send the "break" signal. | |
Error | setCharBits (int bits) |
Set character size. More... | |
Error | setFlowControl (Flow flow) |
Set flow control. More... | |
Error | setParity (Parity parity) |
Set parity mode. More... | |
Error | setSpeed (unsigned long speed) |
Set serial port speed for both input and output. More... | |
Error | setStopBits (int bits) |
Set number of stop bits. More... | |
void | toggleDTR (timeout_t millisec) |
Set the DTR mode off momentarily. 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... | |
![]() | |
static void | concurrency (int level) |
Set concurrency level of process. More... | |
static bool | equal (pthread_t thread1, pthread_t thread2) |
Determine if two thread identifiers refer to the same thread. More... | |
static Thread * | get (void) |
Get mapped thread object. More... | |
static void | init (void) |
Used to initialize threading library. More... | |
static void | policy (int polid) |
Used to specify scheduling policy for threads above priority "0". More... | |
static pthread_t | self (void) |
Get current thread id. More... | |
static void | sleep (timeout_t timeout) |
Sleep current thread for a specified time period. More... | |
static void | yield (void) |
Yield execution context of the current thread. More... | |
![]() | |
volatile bool | joining |
volatile bool | running |
![]() | |
void * | cancellor |
int | priority |
enum ucommon::Thread:: { ... } | reserved |
size_t | stack |
pthread_t | tid |
![]() | |
char * | gbuf |
char * | pbuf |
timeout_t | timeout |
![]() | |
int | bufsize |
fd_t | dev |
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.
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. |