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 16 of file protocolhandler.h.
#include <xSens_MT4/xcommunication/include/xsens/protocolhandler.h>
Public Member Functions | |
ProtocolHandler () | |
Default constructor. More... | |
virtual | ~ProtocolHandler () |
Destructor. More... | |
virtual MessageLocation | findMessage (XsMessage &rcv, const XsByteArray &raw) const |
Find the first message in the raw byte stream. More... | |
virtual int | minimumMessageSize () const |
Returns the minimum size of a valid message of this protocol including preambles and checksums. More... | |
virtual int | maximumMessageSize () const |
Returns the maximum size of a valid message of this protocol including preambles and checksums. More... | |
virtual int | type () const |
Returns the type of the protocol handler. More... | |
Static Public Member Functions | |
static int | composeMessage (XsByteArray &raw, const XsMessage &msg) |
Compose a message for transmission. More... | |
ProtocolHandler::ProtocolHandler | ( | ) |
Default constructor.
Definition at line 25 of file protocolhandler.cpp.
|
virtual |
Destructor.
Definition at line 29 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 189 of file protocolhandler.cpp.
|
virtual |
Find the first message in the raw byte stream.
This function scans raw for a sequence of bytes that it can convert into an XsMessage object. 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:
rcv | If a message is read, it will be put in this object. |
raw | The raw byte stream to analyze. |
Implements IProtocolHandler.
Definition at line 58 of file protocolhandler.cpp.
References expectedMessageSize(), JLALERT, JLTRACE, XsMessageHeader::m_busId, XsMessageHeader::m_length, XsMessageHeader::m_messageId, MessageLocation::m_size, MessageLocation::m_startPos, XS_EXTLENCODE, XS_LEN_MSGEXTHEADERCS, XS_LEN_MSGHEADERCS, XS_MAXDATALEN, and XS_PREAMBLE.
|
virtual |
Returns the maximum size of a valid message of this protocol including preambles and checksums.
Implements IProtocolHandler.
Definition at line 178 of file protocolhandler.cpp.
References XS_LEN_MSGEXTHEADERCS, and XS_MAXDATALEN.
|
virtual |
Returns the minimum size of a valid message of this protocol including preambles and checksums.
Implements IProtocolHandler.
Definition at line 172 of file protocolhandler.cpp.
References XS_LEN_MSGHEADERCS.
|
virtual |
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 198 of file protocolhandler.cpp.
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |