LibSerial 1.0.0
LibSerial provides a convenient, object oriented approach to accessing serial ports on POSIX systems.
|
SerialStreamBuf::Implementation is the SerialStreamBuf implementation class. More...
Public Member Functions | |
Implementation ()=default | |
Default Constructor. | |
~Implementation () | |
Default Destructor. | |
Implementation (const std::string &fileName, const BaudRate &baudRate, const CharacterSize &characterSize, const FlowControl &flowControlType, const Parity &parityType, const StopBits &stopBits, bool exclusive) | |
Constructor that allows a SerialStreamBuf instance to be created and opened, initializing the corresponding serial port with the specified parameters. | |
Implementation (const Implementation &otherImplementation)=delete | |
Copy construction is disallowed. | |
Implementation (const Implementation &&otherImplementation)=delete | |
Move construction is disallowed. | |
Implementation & | operator= (const Implementation &otherImplementation)=delete |
Copy assignment is disallowed. | |
Implementation & | operator= (const Implementation &&otherImplementation)=delete |
Move assignment is disallowed. | |
void | Open (const std::string &fileName, const std::ios_base::openmode &openMode, bool exclusive) |
Opens the serial port associated with the specified file name and the specified mode. | |
void | Close () |
Closes the serial port. All settings of the serial port will be lost and no more I/O can be performed on the serial port. | |
void | DrainWriteBuffer () |
Waits until the write buffer is drained and then returns. | |
void | FlushInputBuffer () |
Flushes the serial port input buffer. | |
void | FlushOutputBuffer () |
Flushes the serial port output buffer. | |
void | FlushIOBuffers () |
Flushes the serial port input and output buffers. | |
bool | IsDataAvailable () |
Determines if data is available at the serial port. | |
bool | IsOpen () const |
Determines if the serial port is open for I/O. | |
void | SetDefaultSerialPortParameters () |
Sets all serial port paramters to their default values. | |
void | SetBaudRate (const BaudRate &baudRate) |
Sets the baud rate for the serial port to the specified value. | |
BaudRate | GetBaudRate () const |
Gets the current baud rate for the serial port. | |
void | SetCharacterSize (const CharacterSize &characterSize) |
Sets the character size for the serial port. | |
CharacterSize | GetCharacterSize () const |
Gets the character size being used for serial communication. | |
void | SetFlowControl (const FlowControl &flowControlType) |
Sets flow control for the serial port. | |
FlowControl | GetFlowControl () const |
Get the current flow control setting. | |
void | SetParity (const Parity &parityType) |
Sets the parity type for the serial port. | |
Parity | GetParity () const |
Gets the parity type for the serial port. | |
void | SetStopBits (const StopBits &stopBits) |
Sets the number of stop bits to be used with the serial port. | |
StopBits | GetStopBits () const |
Gets the number of stop bits currently being used by the serial. | |
void | SetVMin (const short vmin) |
Sets the minimum number of characters for non-canonical reads. | |
short | GetVMin () const |
Gets the VMIN value for the device, which represents the minimum number of characters for non-canonical reads. | |
void | SetVTime (const short vtime) |
Sets character buffer timeout for non-canonical reads in deciseconds. | |
short | GetVTime () const |
Gets the current timeout value for non-canonical reads in deciseconds. | |
void | SetDTR (const bool dtrState) |
Sets the serial port DTR line status. | |
bool | GetDTR () const |
Gets the serial port DTR line status. | |
void | SetRTS (const bool rtsState) |
Sets the serial port RTS line status. | |
bool | GetRTS () const |
Gets the serial port RTS line status. | |
bool | GetCTS () |
Gets the serial port CTS line status. | |
bool | GetDSR () |
Gets the serial port DSR line status. | |
int | GetFileDescriptor () const |
Gets the serial port file descriptor. | |
int | GetNumberOfBytesAvailable () |
Gets the number of bytes available in the read buffer. | |
std::streamsize | xsputn (const char_type *character, std::streamsize numberOfBytes) |
Writes up to n characters from the character sequence at char s to the serial port associated with the buffer. | |
std::streamsize | xsgetn (char_type *character, std::streamsize numberOfBytes) |
Reads up to n characters from the serial port and returns them through the character array located at s. | |
std::streambuf::int_type | overflow (int_type character) |
Writes the specified character to the associated serial port. | |
std::streambuf::int_type | underflow () |
Reads and returns the next character from the associated serial port if one otherwise returns traits::eof(). This method is used for buffered I/O while uflow() is called for unbuffered I/O. | |
std::streambuf::int_type | uflow () |
Reads and returns the next character from the associated serial port if one otherwise returns traits::eof(). This method is used for unbuffered I/O while underflow() is called for unbuffered I/O. | |
std::streambuf::int_type | pbackfail (int_type character) |
This function is called when a putback of a character fails. This must be implemented for unbuffered I/O as all streambuf subclasses are required to provide putback of at least one character. | |
std::streamsize | showmanyc () |
Checks whether input is available on the port. | |
Public Attributes | |
bool | mPutbackAvailable {false} |
True if a putback value is available in mPutbackChar. | |
char | mPutbackChar {0} |
We use unbuffered I/O for the serial port. However, we need to provide the putback of at least one character. This character contains the putback character. | |
SerialStreamBuf::Implementation is the SerialStreamBuf implementation class.
Definition at line 48 of file SerialStreamBuf.cpp.
|
default |
Default Constructor.
|
inline |
Default Destructor.
Definition at line 685 of file SerialStreamBuf.cpp.
|
inline |
Constructor that allows a SerialStreamBuf instance to be created and opened, initializing the corresponding serial port with the specified parameters.
fileName | The file name of the serial stream. |
baudRate | The communications baud rate. |
characterSize | The size of the character buffer for storing read/write streams. |
parityType | The parity type for the serial stream. |
stopBits | The number of stop bits for the serial stream. |
flowControlType | The flow control type for the serial stream. |
exclusive | Set exclusive access for the serial stream. |
-----------------------— Implementation -----------------------—
Definition at line 662 of file SerialStreamBuf.cpp.
|
delete |
Copy construction is disallowed.
|
delete |
Move construction is disallowed.
|
inline |
Closes the serial port. All settings of the serial port will be lost and no more I/O can be performed on the serial port.
Definition at line 734 of file SerialStreamBuf.cpp.
|
inline |
Waits until the write buffer is drained and then returns.
Definition at line 741 of file SerialStreamBuf.cpp.
|
inline |
Flushes the serial port input buffer.
Definition at line 748 of file SerialStreamBuf.cpp.
|
inline |
Flushes the serial port input and output buffers.
Definition at line 762 of file SerialStreamBuf.cpp.
|
inline |
Flushes the serial port output buffer.
Definition at line 755 of file SerialStreamBuf.cpp.
|
inline |
Gets the current baud rate for the serial port.
Definition at line 797 of file SerialStreamBuf.cpp.
|
inline |
Gets the character size being used for serial communication.
Definition at line 811 of file SerialStreamBuf.cpp.
|
inline |
Gets the serial port CTS line status.
Definition at line 916 of file SerialStreamBuf.cpp.
|
inline |
Gets the serial port DSR line status.
Definition at line 923 of file SerialStreamBuf.cpp.
|
inline |
Gets the serial port DTR line status.
Definition at line 895 of file SerialStreamBuf.cpp.
|
inline |
Gets the serial port file descriptor.
Definition at line 930 of file SerialStreamBuf.cpp.
|
inline |
Get the current flow control setting.
Definition at line 825 of file SerialStreamBuf.cpp.
|
inline |
Gets the number of bytes available in the read buffer.
Definition at line 937 of file SerialStreamBuf.cpp.
|
inline |
Gets the parity type for the serial port.
Definition at line 839 of file SerialStreamBuf.cpp.
|
inline |
Gets the serial port RTS line status.
Definition at line 909 of file SerialStreamBuf.cpp.
|
inline |
Gets the number of stop bits currently being used by the serial.
Definition at line 853 of file SerialStreamBuf.cpp.
|
inline |
Gets the VMIN value for the device, which represents the minimum number of characters for non-canonical reads.
Definition at line 867 of file SerialStreamBuf.cpp.
|
inline |
Gets the current timeout value for non-canonical reads in deciseconds.
Definition at line 881 of file SerialStreamBuf.cpp.
|
inline |
Determines if data is available at the serial port.
Definition at line 776 of file SerialStreamBuf.cpp.
|
inline |
Determines if the serial port is open for I/O.
Definition at line 769 of file SerialStreamBuf.cpp.
|
inline |
Opens the serial port associated with the specified file name and the specified mode.
fileName | The file name of the serial port. |
openMode | The communication mode status when the serial communication port is opened. |
exclusive | Set exclusive access for this serial port. |
Definition at line 707 of file SerialStreamBuf.cpp.
|
delete |
Move assignment is disallowed.
|
delete |
Copy assignment is disallowed.
|
inline |
Writes the specified character to the associated serial port.
character | The character to be written to the serial port. |
Definition at line 1068 of file SerialStreamBuf.cpp.
|
inline |
This function is called when a putback of a character fails. This must be implemented for unbuffered I/O as all streambuf subclasses are required to provide putback of at least one character.
character | The character to putback. |
Definition at line 1177 of file SerialStreamBuf.cpp.
|
inline |
Sets the baud rate for the serial port to the specified value.
baudRate | The baud rate to be set for the serial port. |
Definition at line 790 of file SerialStreamBuf.cpp.
|
inline |
Sets the character size for the serial port.
characterSize | The character size to be set. |
Definition at line 804 of file SerialStreamBuf.cpp.
|
inline |
Sets all serial port paramters to their default values.
Definition at line 783 of file SerialStreamBuf.cpp.
|
inline |
Sets the serial port DTR line status.
dtrState | The state to set the DTR line |
Definition at line 888 of file SerialStreamBuf.cpp.
|
inline |
Sets flow control for the serial port.
flowControlType | The flow control type to be set. |
Definition at line 818 of file SerialStreamBuf.cpp.
|
inline |
Sets the parity type for the serial port.
parityType | The parity type to be set. |
Definition at line 832 of file SerialStreamBuf.cpp.
|
inline |
Sets the serial port RTS line status.
rtsState | The state to set the RTS line |
Definition at line 902 of file SerialStreamBuf.cpp.
|
inline |
Sets the number of stop bits to be used with the serial port.
stopBits | The number of stop bits to set. |
Definition at line 846 of file SerialStreamBuf.cpp.
|
inline |
Sets the minimum number of characters for non-canonical reads.
vmin | the number of minimum characters to be set. |
Definition at line 860 of file SerialStreamBuf.cpp.
|
inline |
Sets character buffer timeout for non-canonical reads in deciseconds.
vtime | The timeout value in deciseconds to be set. |
Definition at line 874 of file SerialStreamBuf.cpp.
|
inline |
Checks whether input is available on the port.
Definition at line 1208 of file SerialStreamBuf.cpp.
|
inline |
Reads and returns the next character from the associated serial port if one otherwise returns traits::eof(). This method is used for unbuffered I/O while underflow() is called for unbuffered I/O.
Definition at line 1160 of file SerialStreamBuf.cpp.
|
inline |
Reads and returns the next character from the associated serial port if one otherwise returns traits::eof(). This method is used for buffered I/O while uflow() is called for unbuffered I/O.
Definition at line 1103 of file SerialStreamBuf.cpp.
|
inline |
Reads up to n characters from the serial port and returns them through the character array located at s.
character | Pointer to the character buffer to write to the serial port. |
numberOfBytes | The number of characters to write to the serial port. |
Definition at line 987 of file SerialStreamBuf.cpp.
|
inline |
Writes up to n characters from the character sequence at char s to the serial port associated with the buffer.
character | Pointer to the character buffer to write to the serial port. |
numberOfBytes | The number of characters to write to the serial port. |
Definition at line 953 of file SerialStreamBuf.cpp.
bool LibSerial::SerialStreamBuf::Implementation::mPutbackAvailable {false} |
True if a putback value is available in mPutbackChar.
:TODO: Should this be private?
Definition at line 367 of file SerialStreamBuf.cpp.
char LibSerial::SerialStreamBuf::Implementation::mPutbackChar {0} |
We use unbuffered I/O for the serial port. However, we need to provide the putback of at least one character. This character contains the putback character.
:TODO: Should this be private?
Definition at line 376 of file SerialStreamBuf.cpp.