class Serial

base class for all serial I/O services. More...

Definition#include <serial.h>
Inherited byTTYStream, ttystream, TTYSession, SerialPort
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members


Detailed Description

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.

sioerror_t Error (sioerror_t error, char *errstr = NULL)
[protected]

This service is used to throw all serial errors which usually occur during the serial constructor.

Parameters:
errordefined serial error id.
errstrstring or message to optionally pass.

inline void Error (char *errstr)
[protected]

This service is used to thow application defined serial errors where the application specific error code is a string.

Parameters:
errstrstring or message to pass.

inline void setError (bool enable)
[protected]

This method is used to turn the error handler on or off for "throwing" execptions by manipulating the thrown flag.

Parameters:
trueto enable handler.

int setPacketInput (int size, unsigned char btimer = 0)
[protected]

Set packet read mode and "size" of packet read buffer. This sets VMIN to x. VTIM is normally set to "0" so that "isPending()" can wait for an entire packet rather than just the first byte.

Parameters:
sizeof packet read request.
optionalinter-byte data packet timeout.

Returns: actual buffer size set.

int setLineInput (char newline = 13, char nl1 = 0)
[protected]

Set "line buffering" read mode and specifies the newline character to be used in seperating line records. isPending can then be used to wait for an entire line of input.

Parameters:
newlinecharacter.

Returns: size of conical input buffer.

void Restore (void)
[protected]

Restore serial device to the original settings at time of open.

void flushInput (void)
[protected]

Used to flush the input waiting queue.

void flushOutput (void)
[protected]

Used to flush any pending output data.

void waitOutput (void)
[protected]

Used to wait until all output has been sent.

void endSerial (void)
[protected]

Used as the default destructor for ending serial I/O services. It will restore the port to it's original state.

void initConfig (void)
[protected]

Used to initialize a newly opened serial file handle.

Serial (const char *name)
[protected]

A serial object may be constructed from a named file on the file system. This named device must be "isatty()".

Parameters:
nameof file.

Serial ()
[protected]

This allows later ttystream class to open and close a serial device.

~Serial ()
[virtual]

The serial base class may be "thrown" as a result on an error, and the "catcher" may then choose to destory the object. By assuring the socket base class is a virtual destructor, we can assure the full object is properly terminated.

Serial & operator= (const Serial &from)

Serial ports may also be duplecated by the assignment operator.

sioerror_t setSpeed (unsigned long speed)

Set serial port speed for both input and output.

Parameters:
speedto select.

Returns: 0 on success.

sioerror_t setCharBits (int bits)

Set character size.

Parameters:
charactersize to use (usually 7 or 8).

Returns: 0 on success.

sioerror_t setParity (sioparity_t parity)

Set parity mode.

Parameters:
paritymode.

Returns: 0 on success.

sioerror_t setStopBits (int bits)

Set number of stop bits.

Parameters:
stopbits.

Returns: 0 on success.

sioerror_t setFlowControl (sioflow_t flow)

Set flow control.

Parameters:
flowcontrol mode.

Returns: 0 on success.

inline sioerror_t getErrorNumber (void)

Often used by a "catch" to fetch the last error of a thrown serial.

Returns: error numbr of last sioerror_t.

inline char * getErrorString (void)

Often used by a "catch" to fetch the user set error string of a thrown serial.

Returns: string for error message.

inline int getBufferSize (void)

Get the "buffer" size for buffered operations. This can be used when setting packet or line read modes to determine how many bytes to wait for in a given read call.

Returns: number of bytes used for buffering.

bool isPending (siopend_t pend, timeout_t timeout = ~0)

Get the status of pending operations. This can be used to examine if input or output is waiting, or if an error has occured on the serial device.

Parameters:
readycheck to perform.
timeoutin milliseconds.

Returns: true if ready, false if timeout.