Loading...
Searching...
No Matches
LibSerial::SerialStreamBuf::Implementation Class Reference

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)
| 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)
| 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.

## Detailed Description

SerialStreamBuf::Implementation is the SerialStreamBuf implementation class.

Definition at line 48 of file SerialStreamBuf.cpp.

## Constructor & Destructor Documentation

## Implementation() [1/4]

LibSerial::SerialStreamBuf::Implementation::Implementation | ( |  | ) |

default

Default Constructor.

## ~Implementation()

LibSerial::SerialStreamBuf::Implementation::~Implementation | ( |  | ) |

inline

Default Destructor.

Definition at line 675 of file SerialStreamBuf.cpp.

## Implementation() [2/4]

LibSerial::SerialStreamBuf::Implementation::Implementation | ( | const std::string & | fileName,
|  | const BaudRate & | baudRate,
|  | const CharacterSize & | characterSize,
|  | const FlowControl & | flowControlType,
|  | const Parity & | parityType,
|  | const StopBits & | stopBits
| ) |  |

inline

Constructor that allows a SerialStreamBuf instance to be created and opened, initializing the corresponding serial port with the specified parameters.

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.

-----------------------— Implementation -----------------------—

Definition at line 654 of file SerialStreamBuf.cpp.

## Implementation() [3/4]

LibSerial::SerialStreamBuf::Implementation::Implementation | ( | const Implementation & | otherImplementation | ) |

delete

Copy construction is disallowed.

## Implementation() [4/4]

LibSerial::SerialStreamBuf::Implementation::Implementation | ( | const Implementation && | otherImplementation | ) |

delete

Move construction is disallowed.

## Member Function Documentation

## Close()

void LibSerial::SerialStreamBuf::Implementation::Close | ( |  | ) |

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 722 of file SerialStreamBuf.cpp.

## DrainWriteBuffer()

void LibSerial::SerialStreamBuf::Implementation::DrainWriteBuffer | ( |  | ) |

inline

Waits until the write buffer is drained and then returns.

Definition at line 729 of file SerialStreamBuf.cpp.

## FlushInputBuffer()

void LibSerial::SerialStreamBuf::Implementation::FlushInputBuffer | ( |  | ) |

inline

Flushes the serial port input buffer.

Definition at line 736 of file SerialStreamBuf.cpp.

## FlushIOBuffers()

void LibSerial::SerialStreamBuf::Implementation::FlushIOBuffers | ( |  | ) |

inline

Flushes the serial port input and output buffers.

Definition at line 750 of file SerialStreamBuf.cpp.

## FlushOutputBuffer()

void LibSerial::SerialStreamBuf::Implementation::FlushOutputBuffer | ( |  | ) |

inline

Flushes the serial port output buffer.

Definition at line 743 of file SerialStreamBuf.cpp.

## GetBaudRate()

BaudRate LibSerial::SerialStreamBuf::Implementation::GetBaudRate | ( |  | ) | const

inline

Gets the current baud rate for the serial port.

Returns
  Returns the baud rate.

Definition at line 785 of file SerialStreamBuf.cpp.

## GetCharacterSize()

CharacterSize LibSerial::SerialStreamBuf::Implementation::GetCharacterSize | ( |  | ) | const

inline

Gets the character size being used for serial communication.

Returns
  Returns the current character size.

Definition at line 799 of file SerialStreamBuf.cpp.

## GetCTS()

bool LibSerial::SerialStreamBuf::Implementation::GetCTS | ( |  | ) |

inline

Gets the serial port CTS line status.

Returns
  Returns true iff the status of the CTS line is high.

Definition at line 904 of file SerialStreamBuf.cpp.

## GetDSR()

bool LibSerial::SerialStreamBuf::Implementation::GetDSR | ( |  | ) |

inline

Gets the serial port DSR line status.

Returns
  Returns true iff the status of the DSR line is high.

Definition at line 911 of file SerialStreamBuf.cpp.

## GetDTR()

bool LibSerial::SerialStreamBuf::Implementation::GetDTR | ( |  | ) | const

inline

Gets the serial port DTR line status.

Returns
  Returns true iff the status of the DTR line is high.

Definition at line 883 of file SerialStreamBuf.cpp.

## GetFileDescriptor()

int LibSerial::SerialStreamBuf::Implementation::GetFileDescriptor | ( |  | ) | const

inline

Gets the serial port file descriptor.

Returns
  Returns the serial port file descriptor.

Definition at line 918 of file SerialStreamBuf.cpp.

## GetFlowControl()

FlowControl LibSerial::SerialStreamBuf::Implementation::GetFlowControl | ( |  | ) | const

inline

Get the current flow control setting.

Returns
  Returns the flow control type of the serial port.

Definition at line 813 of file SerialStreamBuf.cpp.

## GetNumberOfBytesAvailable()

int LibSerial::SerialStreamBuf::Implementation::GetNumberOfBytesAvailable | ( |  | ) |

inline

Gets the number of bytes available in the read buffer.

Returns
  Returns the number of bytes avilable in the read buffer.

Definition at line 925 of file SerialStreamBuf.cpp.

## GetParity()

Parity LibSerial::SerialStreamBuf::Implementation::GetParity | ( |  | ) | const

inline

Gets the parity type for the serial port.

Returns
  Returns the parity type.

Definition at line 827 of file SerialStreamBuf.cpp.

## GetRTS()

bool LibSerial::SerialStreamBuf::Implementation::GetRTS | ( |  | ) | const

inline

Gets the serial port RTS line status.

Returns
  Returns true iff the status of the RTS line is high.

Definition at line 897 of file SerialStreamBuf.cpp.

## GetStopBits()

StopBits LibSerial::SerialStreamBuf::Implementation::GetStopBits | ( |  | ) | const

inline

Gets the number of stop bits currently being used by the serial.

Returns
  Returns the number of stop bits.

Definition at line 841 of file SerialStreamBuf.cpp.

## GetVMin()

short LibSerial::SerialStreamBuf::Implementation::GetVMin | ( |  | ) | const

inline

Gets the VMIN value for the device, which represents the minimum number of characters for non-canonical reads.

Returns
  Returns the minimum number of characters for non-canonical reads.

Definition at line 855 of file SerialStreamBuf.cpp.

## GetVTime()

short LibSerial::SerialStreamBuf::Implementation::GetVTime | ( |  | ) | const

inline

Gets the current timeout value for non-canonical reads in deciseconds.

Returns
  Returns the character buffer timeout for non-canonical reads in deciseconds.

Definition at line 869 of file SerialStreamBuf.cpp.

## IsDataAvailable()

bool LibSerial::SerialStreamBuf::Implementation::IsDataAvailable | ( |  | ) |

inline

Determines if data is available at the serial port.

Definition at line 764 of file SerialStreamBuf.cpp.

## IsOpen()

bool LibSerial::SerialStreamBuf::Implementation::IsOpen | ( |  | ) | const

inline

Determines if the serial port is open for I/O.

Returns
  Returns true iff the serial port is open.

Definition at line 757 of file SerialStreamBuf.cpp.

## Open()

void LibSerial::SerialStreamBuf::Implementation::Open | ( | const std::string & | fileName,
|  | const std::ios_base::openmode & | openMode
| ) |  |

inline

Opens the serial port associated with the specified file name and the specified mode.

Parameters

  fileName | The file name of the serial port.
  openMode | The communication mode status when the serial communication port is opened.

Definition at line 697 of file SerialStreamBuf.cpp.

## operator=() [1/2]

Implementation & LibSerial::SerialStreamBuf::Implementation::operator= | ( | const Implementation && | otherImplementation | ) |

delete

Move assignment is disallowed.

## operator=() [2/2]

Implementation & LibSerial::SerialStreamBuf::Implementation::operator= | ( | const Implementation & | otherImplementation | ) |

delete

Copy assignment is disallowed.

## overflow()

std::streambuf::int_type LibSerial::SerialStreamBuf::Implementation::overflow | ( | int_type | character | ) |

inline

Writes the specified character to the associated serial port.

Parameters

  character | The character to be written to the serial port.

Returns
  Returns the character.

Definition at line 1056 of file SerialStreamBuf.cpp.

## pbackfail()

std::streambuf::int_type LibSerial::SerialStreamBuf::Implementation::pbackfail | ( | int_type | character | ) |

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.

Parameters

  character | The character to putback.

Returns
  Returns The character iff successful, otherwise eof to signal an error.

Definition at line 1165 of file SerialStreamBuf.cpp.

## SetBaudRate()

void LibSerial::SerialStreamBuf::Implementation::SetBaudRate | ( | const BaudRate & | baudRate | ) |

inline

Sets the baud rate for the serial port to the specified value.

Parameters

  baudRate | The baud rate to be set for the serial port.

Definition at line 778 of file SerialStreamBuf.cpp.

## SetCharacterSize()

void LibSerial::SerialStreamBuf::Implementation::SetCharacterSize | ( | const CharacterSize & | characterSize | ) |

inline

Sets the character size for the serial port.

Parameters

  characterSize | The character size to be set.

Definition at line 792 of file SerialStreamBuf.cpp.

## SetDefaultSerialPortParameters()

void LibSerial::SerialStreamBuf::Implementation::SetDefaultSerialPortParameters | ( |  | ) |

inline

Sets all serial port paramters to their default values.

Definition at line 771 of file SerialStreamBuf.cpp.

## SetDTR()

void LibSerial::SerialStreamBuf::Implementation::SetDTR | ( | const bool | dtrState | ) |

inline

Sets the serial port DTR line status.

Parameters

  dtrState | The state to set the DTR line

Definition at line 876 of file SerialStreamBuf.cpp.

## SetFlowControl()

void LibSerial::SerialStreamBuf::Implementation::SetFlowControl | ( | const FlowControl & | flowControlType | ) |

inline

Sets flow control for the serial port.

Parameters

  flowControlType | The flow control type to be set.

Definition at line 806 of file SerialStreamBuf.cpp.

## SetParity()

void LibSerial::SerialStreamBuf::Implementation::SetParity | ( | const Parity & | parityType | ) |

inline

Sets the parity type for the serial port.

Parameters

  parityType | The parity type to be set.

Definition at line 820 of file SerialStreamBuf.cpp.

## SetRTS()

void LibSerial::SerialStreamBuf::Implementation::SetRTS | ( | const bool | rtsState | ) |

inline

Sets the serial port RTS line status.

Parameters

  rtsState | The state to set the RTS line

Definition at line 890 of file SerialStreamBuf.cpp.

## SetStopBits()

void LibSerial::SerialStreamBuf::Implementation::SetStopBits | ( | const StopBits & | stopBits | ) |

inline

Sets the number of stop bits to be used with the serial port.

Parameters

  stopBits | The number of stop bits to set.

Definition at line 834 of file SerialStreamBuf.cpp.

## SetVMin()

void LibSerial::SerialStreamBuf::Implementation::SetVMin | ( | const short | vmin | ) |

inline

Sets the minimum number of characters for non-canonical reads.

Parameters

  vmin | the number of minimum characters to be set.

Definition at line 848 of file SerialStreamBuf.cpp.

## SetVTime()

void LibSerial::SerialStreamBuf::Implementation::SetVTime | ( | const short | vtime | ) |

inline

Sets character buffer timeout for non-canonical reads in deciseconds.

Parameters

  vtime | The timeout value in deciseconds to be set.

Definition at line 862 of file SerialStreamBuf.cpp.

## showmanyc()

std::streamsize LibSerial::SerialStreamBuf::Implementation::showmanyc | ( |  | ) |

inline

Checks whether input is available on the port.

Returns
  Returns 1 if characters are available at the serial port, 0 if no characters are available, and -1 if unsuccessful.

Definition at line 1196 of file SerialStreamBuf.cpp.

## uflow()

std::streambuf::int_type LibSerial::SerialStreamBuf::Implementation::uflow | ( |  | ) |

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.

Returns
  Returns the next character from the serial port.

Definition at line 1148 of file SerialStreamBuf.cpp.

## underflow()

std::streambuf::int_type LibSerial::SerialStreamBuf::Implementation::underflow | ( |  | ) |

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.

Returns
  Returns the next character from the serial port.

Definition at line 1091 of file SerialStreamBuf.cpp.

## xsgetn()

std::streamsize LibSerial::SerialStreamBuf::Implementation::xsgetn | ( | char_type * | character,
|  | std::streamsize | numberOfBytes
| ) |  |

inline

Reads up to n characters from the serial port and returns them through the character array located at s.

Parameters

  character | Pointer to the character buffer to write to the serial port.
  numberOfBytes | The number of characters to write to the serial port.

Returns
  Returns the number of characters actually read from the serial port.

Definition at line 975 of file SerialStreamBuf.cpp.

## xsputn()

std::streamsize LibSerial::SerialStreamBuf::Implementation::xsputn | ( | const char_type * | character,
|  | std::streamsize | numberOfBytes
| ) |  |

inline

Writes up to n characters from the character sequence at char s to the serial port associated with the buffer.

Parameters

  character | Pointer to the character buffer to write to the serial port.
  numberOfBytes | The number of characters to write to the serial port.

Returns
  Returns the number of characters that were successfully written to the serial port.

Definition at line 941 of file SerialStreamBuf.cpp.

## Member Data Documentation

## mPutbackAvailable

bool LibSerial::SerialStreamBuf::Implementation::mPutbackAvailable {false}

True if a putback value is available in mPutbackChar.

:TODO: Should this be private?

Definition at line 363 of file SerialStreamBuf.cpp.

## mPutbackChar

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 372 of file SerialStreamBuf.cpp.

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

- src/SerialStreamBuf.cpp