Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ProtocolHandler Class Reference

Message protocol handling class. More...

#include <protocolhandler.h>

Inheritance diagram for ProtocolHandler:
Inheritance graph
[legend]

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...
 
- Public Member Functions inherited from IProtocolHandler
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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ProtocolHandler()

ProtocolHandler::ProtocolHandler ( )

Default constructor.

Definition at line 86 of file protocolhandler.cpp.

◆ ~ProtocolHandler()

ProtocolHandler::~ProtocolHandler ( )
virtual

Destructor.

Definition at line 91 of file protocolhandler.cpp.

Member Function Documentation

◆ composeMessage()

int ProtocolHandler::composeMessage ( XsByteArray raw,
const XsMessage msg 
)
static

Compose a message for transmission.

Parameters
rawThe raw byte array to be constructed from the message
msgThe message to translate into a raw byte array
Returns
The size of the generated byte array

Definition at line 278 of file protocolhandler.cpp.

◆ convertToMessage()

XsMessage ProtocolHandler::convertToMessage ( MessageLocation location,
const XsByteArray raw 
) const
overridevirtual

Converts raw data using location into a XsMessage object.

Parameters
locationThe location of a message to convert from raw data.
rawThe raw byte stream.
Returns
A XsMessage object that was converted from raw byte stream.

Implements IProtocolHandler.

Definition at line 239 of file protocolhandler.cpp.

◆ findMessage()

MessageLocation ProtocolHandler::findMessage ( XsProtocolType type,
const XsByteArray raw 
) const
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:

  • startpos >= 0 and size > 0: A full message with size has been found at startpos.
  • startpos >= 0 and size == 0: The start of a message has been found at startpos, but the size could not yet be determined.
  • startpos >= 0 and size < 0: The start of a message has been found at startpos, and the size of the full message is at least -size.
  • startpos < 0: No messages have been found.
Parameters
typeThe protocol type that was used.
rawThe raw byte stream to analyze.
Returns
A MessageLocation object that describes what was found.

Implements IProtocolHandler.

Definition at line 134 of file protocolhandler.cpp.

◆ ignoreMaximumMessageSize()

void ProtocolHandler::ignoreMaximumMessageSize ( bool  ignore)
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.

Parameters
ignoreSet to true to ignore the maximum message size check.

Reimplemented from IProtocolHandler.

Definition at line 292 of file protocolhandler.cpp.

◆ maximumMessageSize()

int ProtocolHandler::maximumMessageSize ( ) const
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.

◆ minimumMessageSize()

int ProtocolHandler::minimumMessageSize ( ) const
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.

◆ type()

int ProtocolHandler::type ( ) const
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.

Returns
The type id of the protocol handler.

Implements IProtocolHandler.

Definition at line 287 of file protocolhandler.cpp.

◆ XSENS_DISABLE_COPY()

ProtocolHandler::XSENS_DISABLE_COPY ( ProtocolHandler  )

Member Data Documentation

◆ m_ignoreMaxMsgSize

bool ProtocolHandler::m_ignoreMaxMsgSize
private

Definition at line 73 of file protocolhandler.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:22