20 #ifndef _SerialPort_h_ 21 #define _SerialPort_h_ 80 BAUD_460800 = B460800,
81 BAUD_500000 = B500000,
82 BAUD_576000 = B576000,
83 BAUD_921600 = B921600,
84 BAUD_1000000 = B1000000,
85 BAUD_1152000 = B1152000,
86 BAUD_1500000 = B1500000,
87 BAUD_2000000 = B2000000,
88 BAUD_2500000 = B2500000,
89 BAUD_3000000 = B3000000,
90 BAUD_3500000 = B3500000,
91 BAUD_4000000 = B4000000,
128 logic_error(whatArg) { }
135 runtime_error(whatArg) { }
142 logic_error(whatArg) { }
149 runtime_error(whatArg) { }
161 explicit SerialPort(
const std::string& serialPortName ) ;
190 std::invalid_argument ) ;
224 std::invalid_argument ) ;
235 std::runtime_error ) ;
249 std::invalid_argument ) ;
273 std::invalid_argument ) ;
298 std::invalid_argument ) ;
324 std::invalid_argument ) ;
355 ReadByte(
const unsigned int msTimeout = 0 )
358 std::runtime_error ) ;
372 Read( DataBuffer& dataBuffer,
373 const unsigned int numOfBytes = 0,
374 const unsigned int msTimeout = 0 )
377 std::runtime_error ) ;
384 ReadLine( const
unsigned int msTimeout = 0,
385 const
char lineTerminator = '\n' )
388 std::runtime_error ) ;
399 std::runtime_error ) ;
405 Write(const DataBuffer& dataBuffer)
407 std::runtime_error ) ;
413 Write(const std::
string& dataString)
415 std::runtime_error ) ;
421 SetDtr( const
bool dtrState = true )
423 std::runtime_error ) ;
431 std::runtime_error ) ;
437 SetRts( const
bool rtsState = true )
439 std::runtime_error ) ;
447 std::runtime_error ) ;
457 std::runtime_error ) ;
467 std::runtime_error ) ;
504 class SerialPortImpl ;
512 #endif // #ifndef _SerialPort_h_
StopBits GetNumOfStopBits() const
Get the number of stop bits currently being used by the serial port.
AlreadyOpen(const std::string &whatArg)
void Close()
Close the serial port.
std::vector< unsigned char > DataBuffer
Read the specified number of bytes from the serial port.
UnsupportedBaudRate(const std::string &whatArg)
unsigned char ReadByte(const unsigned int msTimeout=0)
Read a single byte from the serial port.
OpenFailed(const std::string &whatArg)
void Read(DataBuffer &dataBuffer, const unsigned int numOfBytes=0, const unsigned int msTimeout=0)
void SetRts(const bool rtsState=true)
Set the RTS line to the specified value.
BaudRate GetBaudRate() const
Get the current baud rate for the serial port.
void Write(const DataBuffer &dataBuffer)
Write the data from the specified vector to the serial port.
const std::string ReadLine(const unsigned int msTimeout=0, const char lineTerminator='\n')
Read a line of characters from the serial port.
bool IsOpen() const
Check if the serial port is open for I/O.
bool GetDtr() const
Get the status of the DTR line.
No parity i.e. parity checking disabled.
void SetBaudRate(const BaudRate baudRate)
Set the baud rate for the serial port to the specified value (baudRate).
FlowControl GetFlowControl() const
Get the current flow control setting.
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)
Open the serial port with the specified settings.
Parity GetParity() const
Get the parity type for the serial port.
void SetDtr(const bool dtrState=true)
Set the DTR line to the specified value.
bool GetRts() const
Get the status of the RTS line.
void SetNumOfStopBits(const StopBits numOfStopBits)
Set the number of stop bits to be used with the serial port.
void SetFlowControl(const FlowControl flowControl)
Set flow control.
int GetFileDescriptor() const
Get the low-level file descriptor associated with the serial port.
CharacterSize GetCharSize() const
Get the current character size for the serial port.
BaudRate
The allowed set of baud rates.
bool IsDataAvailable() const
Check if data is available at the input of the serial port.
SerialPort(const std::string &serialPortName)
Constructor for a serial port.
virtual ~SerialPort()
Destructor.
void WriteByte(const unsigned char dataByte)
Send a single byte to the serial port.
NotOpen(const std::string &whatArg)
void SetCharSize(const CharacterSize charSize)
Set the character size for the serial port.
void SetParity(const Parity parityType)
Set the parity type for the serial port.
SerialPortImpl * mSerialPortImpl
Pointer to implementation class instance.