Logo Search packages:      
Sourcecode: libserial version File versions  Download package

SerialPort Class Reference

#include <SerialPort.h>

List of all members.


Detailed Description

Note:
This class attaches a handler to the SIGIO signal to detect the data arriving at a serial port. However, this signal handler will also call any signal handler that is already attached to this signal. However, if other parts of the application attach a signal handler to SIGIO after constructing an instance of SIGIO, they must ensure that they call the existing signal handler. Otherwise, it may not be possible to receive any data through the serial port using this class.
:FIXME: Provide examples of the above potential problem.

Definition at line 43 of file SerialPort.h.


Public Types

enum  BaudRate {
  BAUD_50 = B50, BAUD_75 = B75, BAUD_110 = B110, BAUD_134 = B134,
  BAUD_150 = B150, BAUD_200 = B200, BAUD_300 = B300, BAUD_600 = B600,
  BAUD_1200 = B1200, BAUD_1800 = B1800, BAUD_2400 = B2400, BAUD_4800 = B4800,
  BAUD_9600 = B9600, BAUD_19200 = B19200, BAUD_38400 = B38400, BAUD_57600 = B57600,
  BAUD_115200 = B115200, BAUD_230400 = B230400, BAUD_DEFAULT = BAUD_57600
}
enum  CharacterSize {
  CHAR_SIZE_5 = CS5, CHAR_SIZE_6 = CS6, CHAR_SIZE_7 = CS7, CHAR_SIZE_8 = CS8,
  CHAR_SIZE_DEFAULT = CHAR_SIZE_8
}
typedef std::vector< unsigned
char > 
DataBuffer
enum  FlowControl { FLOW_CONTROL_HARD, FLOW_CONTROL_NONE, FLOW_CONTROL_DEFAULT = FLOW_CONTROL_NONE }
enum  Parity { PARITY_EVEN, PARITY_ODD, PARITY_NONE, PARITY_DEFAULT = PARITY_NONE }
enum  StopBits { STOP_BITS_1, STOP_BITS_2, STOP_BITS_DEFAULT = STOP_BITS_1 }

Public Member Functions

void Close () throw (NotOpen)
BaudRate GetBaudRate () const throw ( NotOpen, std::runtime_error )
CharacterSize GetCharSize () const throw (NotOpen)
FlowControl GetFlowControl () const throw ( NotOpen )
StopBits GetNumOfStopBits () const throw (NotOpen)
Parity GetParity () const throw (NotOpen)
bool IsDataAvailable () const throw (NotOpen)
bool IsOpen () const
void Open (const BaudRate baudRate=BAUD_DEFAULT, const CharacterSize charSize=CHAR_SIZE_DEFAULT, const Parity parityType=PARITY_DEFAULT, const StopBits stopBits=STOP_BITS_DEFAULT, const FlowControl flowControl=FLOW_CONTROL_DEFAULT) throw ( AlreadyOpen, OpenFailed, UnsupportedBaudRate, std::invalid_argument )
void Read (DataBuffer &dataBuffer, const unsigned int numOfBytes=0, const unsigned int msTimeout=0) throw ( NotOpen, ReadTimeout, std::runtime_error )
unsigned char ReadByte (const unsigned int msTimeout=0) throw ( NotOpen, ReadTimeout, std::runtime_error )
const std::string ReadLine (const unsigned int msTimeout=0, const char lineTerminator= '\n') throw ( NotOpen, ReadTimeout, std::runtime_error )
 SerialPort (const std::string &serialPortName)
void SetBaudRate (const BaudRate baudRate) throw ( UnsupportedBaudRate, NotOpen, std::invalid_argument )
void SetCharSize (const CharacterSize charSize) throw ( NotOpen, std::invalid_argument )
void SetFlowControl (const FlowControl flowControl) throw ( NotOpen, std::invalid_argument )
void SetNumOfStopBits (const StopBits numOfStopBits) throw ( NotOpen, std::invalid_argument )
void SetParity (const Parity parityType) throw ( NotOpen, std::invalid_argument )
void Write (const std::string &dataString) throw ( NotOpen, std::runtime_error )
void Write (const DataBuffer &dataBuffer) throw ( NotOpen, std::runtime_error )
void WriteByte (const unsigned char dataByte) throw ( NotOpen, std::runtime_error )
 ~SerialPort () throw ()

Private Member Functions

SerialPortoperator= (const SerialPort &otherSerialPort)
 SerialPort (const SerialPort &otherSerialPort)

Private Attributes

SerialPortImpl * mSerialPortImpl

Classes

class  AlreadyOpen
class  NotOpen
class  OpenFailed
class  ReadTimeout
class  SerialPortImpl
class  UnsupportedBaudRate

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index