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)
- Public Member Functions inherited from filedescriptor
 filedescriptor ()
 filedescriptor (const filedescriptor &f)
filedescriptoroperator= (const filedescriptor &f)
virtual ~filedescriptor ()
virtual bool close ()
int32_t getFileDescriptor () const
void setFileDescriptor (int32_t filedesc)
int32_t duplicate () const
bool duplicate (int32_t newfd) const
virtual bool useNonBlockingMode () const
virtual bool useBlockingMode () const
bool isUsingNonBlockingMode () const
ssize_t write (uint16_t number) const
ssize_t write (uint32_t number) const
ssize_t write (uint64_t number) const
ssize_t write (int16_t number) const
ssize_t write (int32_t number) const
ssize_t write (int64_t number) const
ssize_t write (float number) const
ssize_t write (double number) const
ssize_t write (unsigned char character) const
ssize_t write (char character) const
ssize_t write (bool value) const
ssize_t write (const unsigned char *string) const
ssize_t write (const char *string) const
ssize_t write (const unsigned char *string, size_t size) const
ssize_t write (const char *string, size_t size) const
ssize_t write (const void *buffer, size_t size) const
ssize_t write (uint16_t number, long sec, long usec) const
ssize_t write (uint32_t number, long sec, long usec) const
ssize_t write (uint64_t number, long sec, long usec) const
ssize_t write (int16_t number, long sec, long usec) const
ssize_t write (int32_t number, long sec, long usec) const
ssize_t write (int64_t number, long sec, long usec) const
ssize_t write (float number, long sec, long usec) const
ssize_t write (double number, long sec, long usec) const
ssize_t write (unsigned char character, long sec, long usec) const
ssize_t write (char character, long sec, long usec) const
ssize_t write (bool value, long sec, long usec) const
ssize_t write (const unsigned char *string, long sec, long usec) const
ssize_t write (const char *string, long sec, long usec) const
ssize_t write (const unsigned char *string, size_t size, long sec, long usec) const
ssize_t write (const char *string, size_t size, long sec, long usec) const
ssize_t write (const void *buffer, size_t size, long sec, long usec) const
ssize_t read (uint16_t *buffer) const
ssize_t read (uint32_t *buffer) const
ssize_t read (uint64_t *buffer) const
ssize_t read (int16_t *buffer) const
ssize_t read (int32_t *buffer) const
ssize_t read (int64_t *buffer) const
ssize_t read (float *buffer) const
ssize_t read (double *buffer) const
ssize_t read (unsigned char *buffer) const
ssize_t read (char *buffer) const
ssize_t read (bool *buffer) const
ssize_t read (unsigned char *buffer, size_t size) const
ssize_t read (char *buffer, size_t size) const
ssize_t read (void *buf, size_t size) const
ssize_t read (char **buffer, const char *terminator) const
ssize_t read (uint16_t *buffer, long sec, long usec) const
ssize_t read (uint32_t *buffer, long sec, long usec) const
ssize_t read (uint64_t *buffer, long sec, long usec) const
ssize_t read (int16_t *buffer, long sec, long usec) const
ssize_t read (int32_t *buffer, long sec, long usec) const
ssize_t read (int64_t *buffer, long sec, long usec) const
ssize_t read (float *buffer, long sec, long usec) const
ssize_t read (double *buffer, long sec, long usec) const
ssize_t read (unsigned char *buffer, long sec, long usec) const
ssize_t read (char *buffer, long sec, long usec) const
ssize_t read (bool *buffer, long sec, long usec) const
ssize_t read (unsigned char *buffer, size_t size, long sec, long usec) const
ssize_t read (char *buffer, size_t size, long sec, long usec) const
ssize_t read (void *buf, size_t size, long sec, long usec) const
ssize_t read (char **buffer, const char *terminator, long sec, long usec) const
int32_t waitForNonBlockingRead (long sec, long usec) const
int32_t waitForNonBlockingWrite (long sec, long usec) const
void retryInterruptedReads ()
void dontRetryInterruptedReads ()
void retryInterruptedWrites ()
void dontRetryInterruptedWrites ()
void retryInterruptedWaits ()
void dontRetryInterruptedWaits ()
void retryInterruptedFcntl ()
void dontRetryInterruptedFcntl ()
void retryInterruptedIoctl ()
void dontRetryInterruptedIoctl ()
void allowShortReads ()
void dontAllowShortReads ()
void allowShortWrites ()
void dontAllowShortWrites ()
void useListener (listener *lstnr)
void dontUseListener ()
listenergetListener ()
void useListenerInsideReads ()
void dontUseListenerInsideReads ()
void useListenerInsideWrites ()
void dontUseListenerInsideWrites ()
virtual bool passFileDescriptor (int32_t fd) const
virtual bool receiveFileDescriptor (int32_t *fd) const
void translateByteOrder ()
void dontTranslateByteOrder ()
int32_t fCntl (int32_t command, long arg) const
int32_t ioCtl (int32_t command, void *arg) const
bool useNaglesAlgorithm ()
bool dontUseNaglesAlgorithm ()
bool setTcpWriteBufferSize (int32_t size)
bool getTcpWriteBufferSize (int32_t *size)
bool setTcpReadBufferSize (int32_t size)
bool getTcpReadBufferSize (int32_t *size)
const char * getType () const
char * getPeerAddress () const
bool setWriteBufferSize (ssize_t size) const
bool flushWriteBuffer (long sec, long usec) const
bool setReadBufferSize (ssize_t size) const
bool closeOnExec ()
bool dontCloseOnExec ()
bool getCloseOnExec ()

Additional Inherited Members

- Static Public Member Functions inherited from filedescriptor
static uint16_t hostToNet (uint16_t value)
static uint32_t hostToNet (uint32_t value)
static uint64_t hostToNet (uint64_t value)
static uint16_t netToHost (uint16_t value)
static uint32_t netToHost (uint32_t value)
static uint64_t netToHost (uint64_t value)

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.