ost::Serial(3) | Library Functions Manual | ost::Serial(3) |
NAME¶
ost::Serial - The Serial class is used as the base for all serial I/O services under APE.SYNOPSIS¶
#include <serial.h> Inherited by ost::SerialPort, and ost::TTYStream.Public Types¶
enum Error { errSuccess = 0, errOpenNoTty, errOpenFailed, errSpeedInvalid, errFlowInvalid, errParityInvalid, errCharsizeInvalid, errStopbitsInvalid, errOptionInvalid, errResourceFailure, errOutput, errInput, errTimeout, errExtended }
Public Member Functions¶
virtual ~Serial ()
Protected Member Functions¶
void open (const char *fname)
Protected Attributes¶
HANDLE dev
Detailed Description¶
The Serial class is used as the base for all serial I/O services under APE.David Sugar dyfet@ostel.com base class for all
serial I/O services.
Member Typedef Documentation¶
typedef enum Error ost::Serial::Error¶
typedef enum Flow ost::Serial::Flow¶
typedef enum Parity ost::Serial::Parity¶
typedef enum Pending ost::Serial::Pending¶
Member Enumeration Documentation¶
enum ost::Serial::Error¶
Enumerator:- errSuccess
- errOpenNoTty
- errOpenFailed
- errSpeedInvalid
- errFlowInvalid
- errParityInvalid
- errCharsizeInvalid
- errStopbitsInvalid
- errOptionInvalid
- errResourceFailure
- errOutput
- errInput
- errTimeout
- errExtended
-
enum ost::Serial::Flow¶
Enumerator:- flowNone
- flowSoft
- flowHard
- flowBoth
-
enum ost::Serial::Parity¶
Enumerator:- parityNone
- parityOdd
- parityEven
-
enum ost::Serial::Pending¶
Enumerator:- pendingInput
- pendingOutput
- pendingError
-
Constructor & Destructor Documentation¶
ost::Serial::Serial () [inline], [protected]¶
This allows later ttystream class to open and close a serial device.ost::Serial::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()'.@param name of file.
virtual ost::Serial::~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.Member Function Documentation¶
virtual int ost::Serial::aRead (char *Data, const intLength) [protected], [virtual]¶
Reads from serial device. Parameters:Data Point to character buffer to
receive data. Buffers MUST be at least Length + 1 bytes in size.
Length Number of bytes to read.
virtual int ost::Serial::aWrite (const char *Data, const intLength) [protected], [virtual]¶
Writes to serial device. Parameters:Data Point to character buffer
containing data to write. Buffers MUST
Length Number of bytes to write.
void ost::Serial::close (void) [protected]¶
Closes the serial device. Reimplemented in ost::ttystream.void ost::Serial::endSerial (void) [protected]¶
Used as the default destructor for ending serial I/O services. It will restore the port to it's original state.Error ost::Serial::error (Errorerror, char *errstr = NULL) [protected]¶
This service is used to throw all serial errors which usually occur during the serial constructor. Parameters:error defined serial error id.
errstr string or message to optionally pass.
void ost::Serial::error (char *err) [inline], [protected]¶
This service is used to thow application defined serial errors where the application specific error code is a string. Parameters:err string or message to pass.
void ost::Serial::flushInput (void) [protected]¶
Used to flush the input waiting queue.void ost::Serial::flushOutput (void) [protected]¶
Used to flush any pending output data.int ost::Serial::getBufferSize (void) [inline]¶
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.
Error ost::Serial::getErrorNumber (void) [inline]¶
Often used by a 'catch' to fetch the last error of a thrown serial. Returns:error numbr of last Error.
char* ost::Serial::getErrorString (void) [inline]¶
Often used by a 'catch' to fetch the user set error string of a thrown serial. Returns:string for error message.
void ost::Serial::initConfig (void) [protected]¶
Used to initialize a newly opened serial file handle. You should set serial properties and DTR manually before first use.virtual bool ost::Serial::isPending (Pendingpend, timeout_ttimeout = TIMEOUT_INF) [virtual]¶
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. Returns:true if ready, false if timeout.
Parameters:
pend ready check to perform.
timeout in milliseconds.
void ost::Serial::open (const char *fname) [protected]¶
Opens the serial device. Parameters:fname Pathname of device to open
Serial& ost::Serial::operator= (const Serial &from)¶
Serial ports may also be duplecated by the assignment operator.void ost::Serial::restore (void) [protected]¶
Restore serial device to the original settings at time of open.void ost::Serial::sendBreak (void)¶
Send the 'break' signal.Error ost::Serial::setCharBits (intbits)¶
Set character size. Returns:0 on success.
Parameters:
bits character size to use (usually 7
or 8).
void ost::Serial::setError (boolenable) [inline], [protected]¶
This method is used to turn the error handler on or off for 'throwing' execptions by manipulating the thrown flag. Parameters:enable true to enable handler.
Error ost::Serial::setFlowControl (Flowflow)¶
Set flow control. Returns:0 on success.
Parameters:
flow control mode.
int ost::Serial::setLineInput (charnewline = 13, charnl1 = 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:newline newline character.
nl1 EOL2 control character.
Returns:
size of conical input buffer.
int ost::Serial::setPacketInput (intsize, unsigned charbtimer = 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. Returns:actual buffer size set.
Parameters:
size of packet read request.
btimer optional inter-byte data packet timeout.
Error ost::Serial::setParity (Parityparity)¶
Set parity mode. Returns:0 on success.
Parameters:
parity mode.
Error ost::Serial::setSpeed (unsigned longspeed)¶
Set serial port speed for both input and output. Returns:0 on success.
Parameters:
speed to select. 0 signifies modem
'hang up'.
Error ost::Serial::setStopBits (intbits)¶
Set number of stop bits. Returns:0 on success.
Parameters:
bits stop bits.
void ost::Serial::toggleDTR (timeout_tmillisec)¶
Set the DTR mode off momentarily. Parameters:millisec number of milliseconds.
void ost::Serial::waitOutput (void) [protected]¶
Used to wait until all output has been sent.Member Data Documentation¶
int ost::Serial::bufsize [protected]¶
HANDLE ost::Serial::dev [protected]¶
bool ost::Serial::linebuf¶
bool ost::Serial::thrown¶
Author¶
Generated automatically by Doxygen for GNU CommonC++ from the source code.Sat Jun 23 2012 | GNU CommonC++ |