|
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 |
|
|
int | getBufferSize (void) const |
| Get the "buffer" size for buffered operations.
|
|
Error | getErrorNumber (void) const |
| Often used by a "catch" to fetch the last error of a thrown serial.
|
|
char * | getErrorString (void) const |
| Often used by a "catch" to fetch the user set error string of a thrown serial.
|
|
virtual bool | isPending (Pending pend, timeout_t timeout=ucommon::Timer::inf) |
| Get the status of pending operations.
|
|
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.
|
|
Error | setFlowControl (Flow flow) |
| Set flow control.
|
|
Error | setParity (Parity parity) |
| Set parity mode.
|
|
Error | setSpeed (unsigned long speed) |
| Set serial port speed for both input and output.
|
|
Error | setStopBits (int bits) |
| Set number of stop bits.
|
|
void | toggleDTR (timeout_t millisec) |
| Set the DTR mode off momentarily.
|
|
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.
|
|
|
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.
|
|
void | close (void) |
| Closes the serial device.
|
|
void | endSerial (void) |
| Used as the default destructor for ending serial I/O services.
|
|
void | error (char *err) |
| This service is used to thow application defined serial errors where the application specific error code is a string.
|
|
Error | error (Error error, char *errstr=NULL) |
| This service is used to throw all serial errors which usually occur during the serial constructor.
|
|
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.
|
|
void | open (const char *fname) |
| Opens the serial device.
|
|
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.
|
|
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 | setLineInput (char newline=13, char nl1=0) |
| Set "line buffering" read mode and specifies the newline character to be used in seperating line records.
|
|
int | setPacketInput (int size, uint8_t btimer=0) |
| Set packet read mode and "size" of packet read buffer.
|
|
void | waitOutput (void) |
| Used to wait until all output has been sent.
|
|
The Serial class is used as the base for all serial I/O services under APE.
A serial is a system serial port that is used either for line or packet based data input. Serial ports may also be "streamable" in a derived form.
Common C++ serial I/O classes are used to manage serial devices and implement serial device protocols. From the point of view of Common C++, serial devices are supported by the underlying Posix specified "termios" call interface.
The serial I/O base class is used to hold a descriptor to a serial device and to provide an exception handling interface for all serial I/O classes. The base class is also used to specify serial I/O properties such as communication speed, flow control, data size, and parity. The "Serial" base class is not itself directly used in application development, however.
Common C++ Serial I/O is itself divided into two conceptual modes; frame oriented and line oriented I/O. Both frame and line oriented I/O makes use of the ability of the underlying tty driver to buffer data and return "ready" status from when select either a specified number of bytes or newline record has been reached by manipulating termios c_cc fields appropriately. This provides some advantage in that a given thread servicing a serial port can block and wait rather than have to continually poll or read each and every byte as soon as it appears at the serial port.
- Author
- David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m
base class for all serial I/O services.
Definition at line 91 of file serial.h.