36#include <libserial/SerialPortConstants.h>
80 const BaudRate& baudRate = BaudRate::BAUD_DEFAULT,
81 const CharacterSize& characterSize = CharacterSize::CHAR_SIZE_DEFAULT,
82 const FlowControl& flowControlType = FlowControl::FLOW_CONTROL_DEFAULT,
83 const Parity& parityType = Parity::PARITY_DEFAULT,
84 const StopBits& stopBits = StopBits::STOP_BITS_DEFAULT) ;
119 void Open(
const std::string& fileName,
120 const std::ios_base::openmode& openMode = std::ios_base::in | std::ios_base::out) ;
205 void SetParity(
const Parity& parityType) ;
230 void SetVMin(
const short vmin) ;
258 void SetDTR(
const bool dtrState =
true) ;
271 void SetRTS(
const bool rtsState =
true) ;
309 std::vector<std::string> GetAvailableSerialPorts()
const ;
334 virtual std::streambuf*
setbuf(char_type* character,
335 std::streamsize numberOfBytes)
override ;
345 virtual std::streamsize
xsputn(
const char_type* character,
346 std::streamsize numberOfBytes)
override ;
356 virtual std::streamsize
xsgetn(char_type* character,
357 std::streamsize numberOfBytes)
override ;
364 virtual int_type
overflow(
const int_type character)
override ;
382 virtual int_type
uflow()
override ;
392 virtual int_type
pbackfail(
const int_type character)
override ;
408 virtual std::streamsize
showmanyc()
override ;
421 std::unique_ptr<Implementation> mImpl;
SerialStreamBuf::Implementation is the SerialStreamBuf implementation class.
SerialStreamBuf is the streambuf subclass used by SerialStream. This subclass takes care of opening t...
CharacterSize GetCharacterSize() const
Gets the character size being used for serial communication.
bool GetCTS()
Get the status of the CTS line.
bool IsOpen() const
Determines if the serial port is open for I/O.
virtual ~SerialStreamBuf()
Default Destructor for a SerialStreamBuf object. Closes the serial port associated with mFileDescript...
virtual std::streambuf * setbuf(char_type *character, std::streamsize numberOfBytes) override
Performs an operation that is defined separately for each class derived from streambuf....
int GetNumberOfBytesAvailable()
Gets the number of bytes available in the read buffer.
virtual std::streamsize showmanyc() override
Checks whether input is available on the port. If you call SerialStream::in_avail,...
virtual int_type overflow(const int_type character) override
Writes the specified character to the associated serial port.
bool IsDataAvailable()
Checks if data is available at the input of the serial port.
virtual int_type pbackfail(const int_type character) override
This function is called when a putback of a character fails. This must be implemented for unbuffered ...
SerialStreamBuf()
Default Constructor.
void FlushOutputBuffer()
Flushes the serial port output buffer.
virtual std::streamsize xsgetn(char_type *character, std::streamsize numberOfBytes) override
Reads up to n characters from the serial port and returns them through the character array located at...
void SetDefaultSerialPortParameters()
Sets all serial port paramters to their default values.
void Open(const std::string &fileName, const std::ios_base::openmode &openMode=std::ios_base::in|std::ios_base::out)
Opens the serial port associated with the specified file name and the specified mode.
SerialStreamBuf(const SerialStreamBuf &&otherSerialStreamBuf)=delete
Move construction is disallowed.
StopBits GetStopBits() const
Gets the number of stop bits currently being used by the serial.
void SetDTR(const bool dtrState=true)
Sets the DTR line to the specified value.
short GetVMin() const
Gets the VMIN value for the device, which represents the minimum number of characters for non-canonic...
bool GetDSR()
Get the status of the DSR line.
virtual std::streamsize xsputn(const char_type *character, std::streamsize numberOfBytes) override
Writes up to n characters from the character sequence at char s to the serial port associated with th...
SerialStreamBuf(const SerialStreamBuf &otherSerialStreamBuf)=delete
Copy construction is disallowed.
void SetVTime(const short vtime)
Sets character buffer timeout for non-canonical reads in deciseconds.
bool GetRTS() const
Get the status of the RTS line.
virtual int_type underflow() override
Reads and returns the next character from the associated serial port if one otherwise returns traits:...
short GetVTime() const
Gets the current timeout value for non-canonical reads in deciseconds.
bool GetDTR() const
Gets the status of the DTR line.
void SetCharacterSize(const CharacterSize &characterSize)
Sets the character size for the serial port.
void SetVMin(const short vmin)
Sets the minimum number of characters for non-canonical reads.
FlowControl GetFlowControl() const
Gets the current flow control setting.
void DrainWriteBuffer()
Waits until the write buffer is drained and then returns.
void Close()
Closes the serial port. All settings of the serial port will be lost and no more I/O can be performed...
BaudRate GetBaudRate() const
Gets the current baud rate for the serial port.
void SetParity(const Parity &parityType)
Sets the parity type for the serial port.
void SetBaudRate(const BaudRate &baudRate)
Sets the baud rate for the serial port to the specified value.
Parity GetParity() const
Gets the parity type for the serial port.
void FlushIOBuffers()
Flushes the serial port input and output buffers.
void SetFlowControl(const FlowControl &flowControlType)
Sets flow control for the serial port.
void FlushInputBuffer()
Flushes the serial port input buffer.
SerialStreamBuf & operator=(const SerialStreamBuf &otherSerialStreamBuf)=delete
Copy assignment is disallowed.
int GetFileDescriptor() const
Gets the serial port file descriptor.
SerialStreamBuf & operator=(const SerialStreamBuf &&otherSerialStreamBuf)=delete
Move assignment is disallowed.
void SetStopBits(const StopBits &stopBits)
Sets the number of stop bits to be used with the serial port.
void SetRTS(const bool rtsState=true)
Set the RTS line to the specified value.
virtual int_type uflow() override
Reads and returns the next character from the associated serial port if one otherwise returns traits:...