Rudiments
Public Member Functions
serialport Class Reference

Inherits filedescriptor.

List of all members.

Public Member Functions

 serialport ()
 serialport (const serialport &s)
serialportoperator= (const serialport &s)
virtual ~serialport ()
bool setProfileNow (serialportprofile *profile)
bool setProfileOnDrain (serialportprofile *profile)
bool setProfileOnFlush (serialportprofile *profile)
bool getProfile (serialportprofile *profile)
bool drain ()
bool flush ()
bool flushInput ()
bool flushOutput ()
bool suspendOutput ()
bool restartOutput ()
bool transmitStop ()
bool transmitStart ()
bool sendBreak (int32_t duration)

Detailed Description

The serialport class is similar to the filedescriptor class, but read() returns EOF when a timeout has occurred. This class should be used when communicating over a serial port.

Also, this class wraps some functions from termios.h


Constructor & Destructor Documentation

serialport::serialport ( )

Creates an instance of the serialport class.

serialport::serialport ( const serialport s)

Creates an instance of the serialport class that is identical to "s".

virtual serialport::~serialport ( ) [virtual]

Deletes this instance of the serialport class.


Member Function Documentation

bool serialport::drain ( )

Waits until all output written to the serial port has been transmitted.

bool serialport::flush ( )

Discards all output written to the serial port but not yet transmitted and all buffered input.

bool serialport::flushInput ( )

Discards all buffered input.

bool serialport::flushOutput ( )

Discards all output written to the serial port but not yet transmitted.

bool serialport::getProfile ( serialportprofile profile)

Sets "profile" to the current profile of the serial port.

serialport& serialport::operator= ( const serialport s)

Makes this instance of the serialport class identical to "s".

bool serialport::restartOutput ( )

Restores output operations suspended by a call to suspendOutput().

bool serialport::sendBreak ( int32_t  duration)

If the DTE is communicating asynchronously, then a continuous stream of 0-valued bytes are sent to the DTE. If "duration" is 0 then the stream will be sent for between 0.25 and 0.5 seconds. If "duration" is non-zero then the stream will be sent for an implementation-specific period of time.

If the DTE is communicating synchronously, then this method does nothing and returns true immediately.

bool serialport::setProfileNow ( serialportprofile profile)

Sets the profile of the serial port to "profile" immediately.

bool serialport::setProfileOnDrain ( serialportprofile profile)

Sets the profile of the serial port to "profile" after all output written to the serial port has been transmitted.

bool serialport::setProfileOnFlush ( serialportprofile profile)

Sets the profile of the serial port to "profile" after all output written to the serial port has been transmitted. Also discards all buffered input.

bool serialport::suspendOutput ( )

Causes data not yet written not to be written until restartOutput() is called. New writes will block when the output buffer is full.

bool serialport::transmitStart ( )

Sends a START character out the serial port, hopefully causing the DTE to resume transmission.

bool serialport::transmitStop ( )

Sends a STOP character out the serial port, hopefully causing the DTE cease transmitting data until a START character is sent.