Message protocol handling class. More...
#include <protocolhandler.h>
Public Member Functions | |
XsMessage | convertToMessage (MessageLocation &location, const XsByteArray &raw) const override |
Converts raw data using location into a XsMessage object. More... | |
MessageLocation | findMessage (XsProtocolType &type, const XsByteArray &raw) const override |
Find the first message in the raw byte stream. More... | |
void | ignoreMaximumMessageSize (bool ignore) override |
Tells the protocol handler to ignore/expand its maximum message size. More... | |
int | maximumMessageSize () const override |
Returns the maximum size of a valid message of this protocol including preambles and checksums. More... | |
int | minimumMessageSize () const override |
Returns the minimum size of a valid message of this protocol including preambles and checksums. More... | |
ProtocolHandler () | |
Default constructor. More... | |
int | type () const override |
Returns the type of the protocol handler. More... | |
XSENS_DISABLE_COPY (ProtocolHandler) | |
virtual | ~ProtocolHandler () |
Destructor. More... | |
![]() | |
virtual bool | setEnable (bool enable) |
Enables or disables the protocol handler if supported. A disabled protocol handler ignores and discards all data provided through the findMessage function. More... | |
virtual | ~IProtocolHandler () |
Destructor. More... | |
Static Public Member Functions | |
static int | composeMessage (XsByteArray &raw, const XsMessage &msg) |
Compose a message for transmission. More... | |
Private Attributes | |
bool | m_ignoreMaxMsgSize |
Message protocol handling class.
This class' purpose is to get valid messages according to its protocol from the raw data that is supplied to it. The default implementation (ProtocolHandler) implements the Xsens message protocol. To use a different protocol, overload the findMessage function.
The class is intended to be state-less with respect to the data it handles.
Definition at line 71 of file protocolhandler.h.
ProtocolHandler::ProtocolHandler | ( | ) |
Default constructor.
Definition at line 86 of file protocolhandler.cpp.
|
virtual |
Destructor.
Definition at line 91 of file protocolhandler.cpp.
|
static |
Compose a message for transmission.
raw | The raw byte array to be constructed from the message |
msg | The message to translate into a raw byte array |
Definition at line 278 of file protocolhandler.cpp.
|
overridevirtual |
Converts raw data using location into a XsMessage object.
location | The location of a message to convert from raw data. |
raw | The raw byte stream. |
Implements IProtocolHandler.
Definition at line 239 of file protocolhandler.cpp.
|
overridevirtual |
Find the first message in the raw byte stream.
This function scans raw for a sequence of bytes that can contain a full message. It returns the location and total byte size of the message so that the caller can remove those bytes from the stream. The return value can also describe that a partial message has been found. Return values:
type | The protocol type that was used. |
raw | The raw byte stream to analyze. |
Implements IProtocolHandler.
Definition at line 134 of file protocolhandler.cpp.
|
overridevirtual |
Tells the protocol handler to ignore/expand its maximum message size.
This is mostly used when reading from a file that is known to contain correct data. Please note that the protocol handler can decide to ignore this call, which is what the default implementation does.
ignore | Set to true to ignore the maximum message size check. |
Reimplemented from IProtocolHandler.
Definition at line 292 of file protocolhandler.cpp.
|
overridevirtual |
Returns the maximum size of a valid message of this protocol including preambles and checksums.
Implements IProtocolHandler.
Definition at line 268 of file protocolhandler.cpp.
|
overridevirtual |
Returns the minimum size of a valid message of this protocol including preambles and checksums.
Implements IProtocolHandler.
Definition at line 262 of file protocolhandler.cpp.
|
overridevirtual |
Returns the type of the protocol handler.
Each protocol handler has a locally unique id that can be used for instantiation of the correct protocol handler.
Implements IProtocolHandler.
Definition at line 287 of file protocolhandler.cpp.
ProtocolHandler::XSENS_DISABLE_COPY | ( | ProtocolHandler | ) |
|
private |
Definition at line 73 of file protocolhandler.h.