Connection_Impl_Base
Connection_Impl_Base
Connection_Impl

An Abstract Base Class for various connection types.

Functions
~Connection_Impl_Base
virtual ~Connection_Impl_Base()

Destroys the Connection_Impl_Base object

establishConnection
virtual void establishConnection() = 0

Initializes and opens the current connection.

description
virtual std::string description() = 0

Gets a description of the connection as a string

Returns

A description of the connection

disconnect
virtual void disconnect() = 0

Closes the current connection.

reconnect
virtual void reconnect() = 0

Reopens a connection that has been disconnected.

registerParser
virtual void registerParser(
std::function<void(DataBuffer&)> parseFunction
) = 0

Registers a function to handle the parsing of data when it is read in.

Parameters
parseFunction
std::function<void(DataBuffer&)>

The function to call to parse data that is read in.

Exceptions
unregisterParser
virtual void unregisterParser() = 0

Unregisters the function to handle the parsing of data when it is read in

throwIfError
virtual void throwIfError() = 0

Throws an exception if a connection error has occurred.

Exceptions
write
virtual void write(
const ByteStream &data
) = 0

Writes bytes to the port via the BoostCommunication object.

Parameters
data
const ByteStream&

the bytes that will be written to the port.

Exceptions
write
virtual void write(
const Bytes &bytes
) = 0

Writes the given bytes to the port via the BoostCommunication object.

Parameters
bytes
const Bytes&

The bytes to write.

Exceptions
clearBuffer
virtual void clearBuffer() = 0

Resets the read buffer.

byteReadPos
virtual std::size_t byteReadPos() const = 0

Gets the read position from the byte buffer.

byteAppendPos
virtual std::size_t byteAppendPos() const = 0

Gets the append position from the byte buffer.

rawByteMode
virtual void rawByteMode(
bool enable
) = 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.

Parameters
enable
bool

whether to enable raw byte mode (true), or disable raw byte mode (false).

Exceptions
getRawBytes
virtual void getRawBytes(
Bytes &bytes,
uint32 timeout 0,
uint32 maxBytes 0
) = 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.

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