An Abstract Base Class for various connection types.
Destroys the Connection_Impl_Base object
Initializes and opens the current connection.
Gets a description of the connection as a string
A description of the connection
Closes the current connection.
Reopens a connection that has been disconnected.
virtual void registerParser( |
| ) = 0 |
Registers a function to handle the parsing of data when it is read in.
parseFunction | The function to call to parse data that is read in. |
Error_Connection: The connection is already in use.
Unregisters the function to handle the parsing of data when it is read in
Throws an exception if a connection error has occurred.
Error_Connection: a connection error has occurred.
virtual void write( |
| ) = 0 |
Writes bytes to the port via the BoostCommunication object.
data const ByteStream& | the bytes that will be written to the port. |
Error_Connection: a connection error has occurred, such as the device being unplugged.
virtual void write( |
| ) = 0 |
Writes the given bytes to the port via the BoostCommunication object.
bytes const Bytes& | The bytes to write. |
Error_Connection: a connection error has occurred, such as the device being unplugged.
Resets the read buffer.
Gets the read position from the byte buffer.
Gets the append position from the byte buffer.
virtual void rawByteMode( |
| ) = 0 |
Puts the connection into "Raw Byte Mode." "Raw Byte Mode" stops the data from being sent/parsed from any attached devices (BaseStation, InertialNode, etc.) and instead sends all data into a raw circular data buffer that can be accessed by calling getRawBytes on this Connection object. Disabling this mode will start sending all data back to the previous attached device, if still available.
enable bool | whether to enable raw byte mode (true), or disable raw byte mode (false). |
Error_Connection: The connection has been disconnected.
virtual void getRawBytes( |
| ) = 0 |
Gets all of the raw bytes that are available that have been collected when the Connection is in "Raw Byte Mode." If the Connection has not been put into "Raw Byte Mode" by calling rawByteMode, no data can be retrieved from this function.
bytes | A Bytes vector to hold the result. |
timeout uint32 | the timeout, in milliseconds, to wait for the data if necessary (default of 0). |
maxBytes uint32 | The maximum number of bytes to return. If this is 0 (default), all bytes will be returned. |
An Abstract Base Class for various connection types. This class uses a template for the Comm Object and contains default functionality for connection types.
Destroys the Connection_Impl object
A BoostCommunication object used for actual read/write operations.
The boost::asio::io_service object.
The actual boost communication object (ex. boost::asio::serial_port, tcp::socket, etc.)
The thread used to run the operation of reading in bytes from the BaseStation.
true if the connection has been established, false otherwise.
std::function<void( |
| )> m_parseFunction |
The function to call to parse data that is read in.
The circular buffer to store data when in "Raw Byte Mode."
Allows the raw byte buffer to know when data has been added.
true if an error has occurred with the connection, false otherwise.
The error code of the connection error, if there was a connection error.
The error message of the connection error, if there was a connection error.
true if the connection is in "Raw Byte Mode", false otherwise.
The mutex used to access the "Raw Byte Mode" buffer.
Initializes and opens the current connection.
Gets a description of the connection as a string.
A description of the connection.
Closes the current connection.
Reopens a connection that has been disconnected.
virtual void registerParser( |
| ) final |
Registers a function to handle the parsing of data when it is read in.
parseFunction | The function to call to parse data that is read in. |
Error: a data parsing function has already been registered.
Unregisters the function to handle the parsing of data when it is read in.
Throws an exception if a connection error has occurred.
Error_Connection: a connection error has occurred.
virtual void write( |
| ) final |
Writes bytes to the port via the BoostCommunication object.
data const ByteStream& | the bytes that will be written to the port. |
Error_Connection: a connection error has occurred, such as the device being unplugged.
virtual void write( |
| ) final |
Writes the given bytes to the port via the BoostCommunication object.
bytes const Bytes& | The bytes to write. |
Error_Connection: a connection error has occurred, such as the device being unplugged.
Clears the read buffer.
Gets the read position from the byte buffer.
Gets the append position from the byte buffer.
Starts the main thread for reading in all the data and handling write commands
Stops the main thread, canceling all reading and writing
virtual void rawByteMode( |
| ) final |
Puts the connection into "Raw Byte Mode." "Raw Byte Mode" stops the data from being sent/parsed from any attached devices (BaseStation, InertialNode, etc.) and instead sends all data into a raw circular data buffer that can be accessed by calling getRawBytes on this Connection object. Disabling this mode will start sending all data back to the previous attached device, if still available.
enable bool | whether to enable raw byte mode (true), or disable raw byte mode (false). |
Error_Connection: The connection has been disconnected.
virtual void getRawBytes( |
| ) final |
Gets all of the raw bytes that are available that have been collected when the Connection is in "Raw Byte Mode." If the Connection has not been put into "Raw Byte Mode" by calling rawByteMode, no data can be retrieved from this function.
bytes | A Bytes vector to hold the result. |
timeout uint32 | the timeout, in milliseconds, to wait for the data if necessary (default of 0). |
maxBytes uint32 | The maximum number of bytes to return. If this is 0 (default), all bytes will be returned. |
void collectRawData( |
| ) |
The function to be sent to the communication object to parse data for "Raw Byte Mode."
data | The DataBuffer that contains all of the data that was read in from the connection. |