Main MRPT website > C++ reference for MRPT 1.5.9
List of all members | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
xsens::Message Class Reference

Detailed Description

Class for storing a single message.

Definition at line 76 of file cmtmessage.h.

#include <xSens_MT3/cmtmessage.h>

Public Member Functions

 Message (const uint8_t msgId=0, const uint16_t length=0, const uint16_t maxLength=CMT_MAXMSGLEN)
 Create a Message object with the given data length and message Id. More...
 
 Message (const uint8_t *source, const uint16_t size, const uint16_t maxLength=CMT_MAXMSGLEN)
 Create a message from the given source string. More...
 
 Message (const Message &src)
 
 ~Message ()
 Destructor. More...
 
void clear (void)
 Clear all data in the message. More...
 
uint8_t getBusId (void) const
 Return the current value of the m_busId field. More...
 
uint8_tgetDataBuffer (const uint16_t offset=0)
 Return a pointer to the data buffer. More...
 
const uint8_tgetDataBuffer (const uint16_t offset=0) const
 
uint8_t getDataByte (const uint16_t offset=0) const
 Return the current value of the data as an unsigned byte (8 bits). More...
 
double getDataDouble (const uint16_t offset=0) const
 Return the current value of the data as a double (64 bits). More...
 
float getDataFloat (const uint16_t offset=0) const
 Return the current value of the data as a float (32 bits). More...
 
double getDataF1220 (const uint16_t offset=0) const
 Return the current value of the data as a double, converting it from FP 12.20. More...
 
double getDataFP1632 (const uint16_t offset=0) const
 Return the current value of the data as a double, converting it from FP 16.32. More...
 
double getDataFPValue (const uint64_t outputSettings, const uint16_t offset=0) const
 Return current data value as double, conversion depends on outputSettings. More...
 
void getDataFPValue (double *dest, const uint64_t outputSettings, uint16_t offset, const int16_t numValues) const
 Return current data values as double, conversion depends on outputSetting. More...
 
uint32_t getDataLong (const uint16_t offset=0) const
 Return the current value of the data as an uint32_t (32 bits). More...
 
uint16_t getDataShort (const uint16_t offset=0) const
 Return the current value of the data as an uint16_t (16 bits). More...
 
uint16_t getDataSize (void) const
 Return the length of the data part of the message. More...
 
uint8_t getMessageId (void) const
 Return the current value of the m_messageId field. More...
 
const uint8_tgetMessageStart (void) const
 Return the start of the message buffer. More...
 
uint16_t getTotalMessageSize (void) const
 Return the length of the message buffer. More...
 
bool isChecksumOk (void) const
 Compute the checksum and compare it with the stored checksum. Equal is ok. More...
 
XsensResultValue loadFromString (const uint8_t *source, const uint16_t size)
 Read the entire message from the given source string. More...
 
void recomputeChecksum (void)
 Compute the checksum field and fill it. More...
 
void resizeData (const uint16_t newSize)
 Resize the data area to the given size. More...
 
void setBusId (const uint8_t busId)
 Set the new value of the m_busId field and update the checksum. More...
 
void setDataBuffer (const uint8_t *data, const uint16_t offset=0, const uint16_t count=0)
 Write a string of bytes into the data buffer. More...
 
void setDataByte (const uint8_t data, const uint16_t offset=0)
 Write an unsigned byte (8 bits) into the data buffer. More...
 
void setDataDouble (const double data, const uint16_t offset=0)
 Write a double (64 bits) into the data buffer. More...
 
void setDataFloat (const float data, const uint16_t offset=0)
 Write a float (32 bits) into the data buffer. More...
 
void setDataF1220 (const double data, const uint16_t offset=0)
 Write a double (64 bits) into the data buffer, after converting it to F1220. More...
 
void setDataFP1632 (const double data, const uint16_t offset=0)
 Write a double (64 bits) into the data buffer, after converting it to FP1632. More...
 
void setDataFPValue (const uint64_t outputSettings, const double data, const uint16_t offset=0)
 Write a floating/fixed point value into to the data buffer, conversion depends on outputSettings. More...
 
void setDataFPValue (const uint64_t outputSettings, const double *data, uint16_t offset, const uint16_t numValues)
 Write a floating/fixed point value into to the data buffer, conversion depends on outputSettings. More...
 
void setDataLong (const uint32_t data, const uint16_t offset=0)
 Write an uint32_t (32 bits) into the data buffer. More...
 
void setDataShort (const uint16_t data, const uint16_t offset=0)
 Write an uint16_t (16 bits) into the data buffer. More...
 
void setMessageId (const uint8_t msgId)
 Set the new value of the m_messageId field and update the checksum. More...
 
void operator= (const Message &src)
 Copy message src into this. More...
 
void deleteData (uint16_t size, uint16_t offset=0)
 Remove a number of bytes from the message (this will reduce the message size) More...
 
void insertData (uint16_t size, uint16_t offset=0)
 Insert a number of bytes into the message (this will increase the message size) More...
 

Public Attributes

bool m_autoUpdateChecksum
 

Protected Member Functions

uint8_t calcChecksum (void) const
 Internal checksum computation. More...
 
uint8_tgetDataStart (void) const
 Internal function to get the start of the data buffer. More...
 

Protected Attributes

CMT_CHECKVAR MessageHeaderm_buffer
 The message header is the data buffer with interpretation. More...
 
uint8_tm_checksum
 The checksum in the m_data or m_extendedData buffer. More...
 
uint32_t m_maxLength
 The maximum size of the message, including header and footer. More...
 

Constructor & Destructor Documentation

◆ Message() [1/3]

xsens::Message::Message ( const uint8_t  msgId = 0,
const uint16_t  length = 0,
const uint16_t  maxLength = CMT_MAXMSGLEN 
)

Create a Message object with the given data length and message Id.

The function allocates enough memory to hold an entire message with the given data length.

Parameters
msgIdThe message Id that will be assigend to the m_messageId field.
lengthThe length of the data in the message. This value is stored in m_createdLength as well as m_length or m_extendedLength.
maxLengthThe maximum data length that can be stored in the structure.

Definition at line 41 of file cmtmessage.cpp.

References CMT_BID_MASTER, CMT_CHECKASSIGN, CMT_EXTLENCODE, CMT_LEN_MSGEXTHEADER, CMT_LEN_MSGHEADER, CMT_MAXMSGLEN, CMT_PREAMBLE, m_autoUpdateChecksum, m_buffer, xsens::MessageHeader::m_busId, m_checksum, xsens::MessageHeader::m_datlen, xsens::MessageHeader::_mdl::m_extended, xsens::MessageHeader::_mdl::_mextd::_mlen::m_high, xsens::MessageHeader::m_length, xsens::MessageHeader::_mdl::_mextd::m_length, xsens::MessageHeader::_mdl::_mextd::_mlen::m_low, m_maxLength, xsens::MessageHeader::m_messageId, xsens::MessageHeader::m_preamble, and MSGLOG.

◆ Message() [2/3]

xsens::Message::Message ( const uint8_t source,
const uint16_t  size,
const uint16_t  maxLength = CMT_MAXMSGLEN 
)

Create a message from the given source string.

This is done through a simple memory copy. The number of bytes copied is taken from the data in the message (so the message is interpreted first). Note that this does NOT recompute the checksum, nor is it checked.

Parameters
sourceThe source string containing message data
sizeThe size of the source string
maxLengthThe maximum data length that can be stored in the structure.

Definition at line 80 of file cmtmessage.cpp.

References CMT_CHECKASSIGN, CMT_EXTLENCODE, CMT_LEN_MSGEXTHEADERCS, CMT_LEN_MSGHEADERCS, CMT_MAXMSGLEN, m_autoUpdateChecksum, m_buffer, m_checksum, m_maxLength, mrpt::system::os::memcpy(), and MSGLOG.

◆ Message() [3/3]

xsens::Message::Message ( const Message src)

◆ ~Message()

xsens::Message::~Message ( )

Destructor.

Definition at line 128 of file cmtmessage.cpp.

References CMT_CHECKASSERT, m_buffer, and MSGLOG.

Member Function Documentation

◆ calcChecksum()

uint8_t xsens::Message::calcChecksum ( void  ) const
inlineprotected

Internal checksum computation.

Definition at line 88 of file cmtmessage.h.

References xsens::computeChecksum(), getTotalMessageSize(), and m_buffer.

Referenced by isChecksumOk(), loadFromString(), and recomputeChecksum().

◆ clear()

void xsens::Message::clear ( void  )

◆ deleteData()

void xsens::Message::deleteData ( uint16_t  size,
uint16_t  offset = 0 
)

Remove a number of bytes from the message (this will reduce the message size)

Definition at line 716 of file cmtmessage.cpp.

References getDataBuffer(), getDataSize(), and resizeData().

Referenced by xsens::Packet::setXbus().

◆ getBusId()

uint8_t xsens::Message::getBusId ( void  ) const
inline

Return the current value of the m_busId field.

Definition at line 128 of file cmtmessage.h.

References m_buffer, and xsens::MessageHeader::m_busId.

◆ getDataBuffer() [1/2]

uint8_t* xsens::Message::getDataBuffer ( const uint16_t  offset = 0)
inline

Return a pointer to the data buffer.

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 133 of file cmtmessage.h.

References getDataStart().

Referenced by deleteData(), xsens::Cmt3::getAvailableScenarios(), xsens::Cmt3::getConfiguration(), xsens::Cmt3::getEMtsData(), xsens::Cmt3::getProductCode(), xsens::Packet::getRawData(), insertData(), and CmtDeviceConfiguration::readFromMessage().

◆ getDataBuffer() [2/2]

const uint8_t* xsens::Message::getDataBuffer ( const uint16_t  offset = 0) const
inline

Definition at line 135 of file cmtmessage.h.

References getDataStart().

◆ getDataByte()

uint8_t xsens::Message::getDataByte ( const uint16_t  offset = 0) const
inline

◆ getDataDouble()

double xsens::Message::getDataDouble ( const uint16_t  offset = 0) const

Return the current value of the data as a double (64 bits).

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 150 of file cmtmessage.cpp.

References CMT_CHECKASSERT, and getDataStart().

Referenced by getDataFPValue().

◆ getDataF1220()

double xsens::Message::getDataF1220 ( const uint16_t  offset = 0) const

Return the current value of the data as a double, converting it from FP 12.20.

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 180 of file cmtmessage.cpp.

References CMT_CHECKASSERT, and getDataStart().

Referenced by getDataFPValue().

◆ getDataFloat()

float xsens::Message::getDataFloat ( const uint16_t  offset = 0) const

Return the current value of the data as a float (32 bits).

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 164 of file cmtmessage.cpp.

References CMT_CHECKASSERT, and getDataStart().

Referenced by getDataFPValue(), xsens::Cmt3::getGpsLeverArm(), xsens::Cmt3::getGravityMagnitude(), xsens::Cmt3::getHeading(), and xsens::Cmt3::getMagneticDeclination().

◆ getDataFP1632()

double xsens::Message::getDataFP1632 ( const uint16_t  offset = 0) const

Return the current value of the data as a double, converting it from FP 16.32.

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 217 of file cmtmessage.cpp.

References CMT_CHECKASSERT, getDataStart(), xsens::Itypes::i0, xsens::Itypes::i1, xsens::Itypes::i32, and xsens::Itypes::i64.

Referenced by getDataFPValue().

◆ getDataFPValue() [1/2]

double xsens::Message::getDataFPValue ( const uint64_t  outputSettings,
const uint16_t  offset = 0 
) const

◆ getDataFPValue() [2/2]

void xsens::Message::getDataFPValue ( double *  dest,
const uint64_t  outputSettings,
uint16_t  offset,
const int16_t  numValues 
) const

Return current data values as double, conversion depends on outputSetting.

Parameters
destdestination array
outputSettingsMT output settings
offsetoffset in the data buffer from where to start reading.
numValuesnumber of values to be read

Definition at line 267 of file cmtmessage.cpp.

References CMT_OUTPUTSETTINGS_DATAFORMAT_DOUBLE, CMT_OUTPUTSETTINGS_DATAFORMAT_F1220, CMT_OUTPUTSETTINGS_DATAFORMAT_FLOAT, CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632, CMT_OUTPUTSETTINGS_DATAFORMAT_MASK, getDataDouble(), getDataF1220(), getDataFloat(), and getDataFP1632().

◆ getDataLong()

uint32_t xsens::Message::getDataLong ( const uint16_t  offset = 0) const

Return the current value of the data as an uint32_t (32 bits).

Parameters
offsetAn optional offset in the data buffer from where to start reading.

Definition at line 296 of file cmtmessage.cpp.

References CMT_CHECKASSERT, and getDataStart().

Referenced by xsens::Packet::getRawGpsData(), xsens::Cmt3::getSyncInOffset(), xsens::Cmt3::getSyncInSettings(), xsens::Cmt3::getSyncOutOffset(), xsens::Cmt3::getSyncOutPulseWidth(), xsens::Cmt3::getSyncOutSettings(), xsens::Cmt3::getUtcTime(), and CmtDeviceConfiguration::readFromMessage().

◆ getDataShort()

uint16_t xsens::Message::getDataShort ( const uint16_t  offset = 0) const

◆ getDataSize()

uint16_t xsens::Message::getDataSize ( void  ) const

◆ getDataStart()

uint8_t * xsens::Message::getDataStart ( void  ) const
protected

◆ getMessageId()

uint8_t xsens::Message::getMessageId ( void  ) const
inline

◆ getMessageStart()

const uint8_t* xsens::Message::getMessageStart ( void  ) const
inline

Return the start of the message buffer.

The function returns the address of the m_preamble member.

Definition at line 195 of file cmtmessage.h.

References m_buffer.

Referenced by xsens::Cmt2s::readMessage(), xsens::Cmt3::refreshCache(), xsens::Cmt2s::writeMessage(), and xsens::Cmt2f::writeMessage().

◆ getTotalMessageSize()

uint16_t xsens::Message::getTotalMessageSize ( void  ) const

Return the length of the message buffer.

The function returns the total size of the message, including the checksum. This is in effect the number of bytes that would be transferred if the message were to be sent over a communications channel.

Definition at line 350 of file cmtmessage.cpp.

References CMT_CHECKASSERT, CMT_LEN_MSGEXTHEADERCS, CMT_LEN_MSGHEADERCS, m_buffer, xsens::MessageHeader::m_datlen, xsens::MessageHeader::_mdl::m_extended, xsens::MessageHeader::_mdl::_mextd::_mlen::m_high, xsens::MessageHeader::m_length, xsens::MessageHeader::_mdl::_mextd::m_length, and xsens::MessageHeader::_mdl::_mextd::_mlen::m_low.

Referenced by calcChecksum(), isChecksumOk(), xsens::Cmt2s::writeMessage(), and xsens::Cmt2f::writeMessage().

◆ insertData()

void xsens::Message::insertData ( uint16_t  size,
uint16_t  offset = 0 
)

Insert a number of bytes into the message (this will increase the message size)

Definition at line 741 of file cmtmessage.cpp.

References getDataBuffer(), getDataSize(), and resizeData().

Referenced by xsens::Packet::setXbus().

◆ isChecksumOk()

bool xsens::Message::isChecksumOk ( void  ) const

Compute the checksum and compare it with the stored checksum. Equal is ok.

Definition at line 360 of file cmtmessage.cpp.

References calcChecksum(), getTotalMessageSize(), m_checksum, and m_maxLength.

Referenced by xsens::findValidMessage().

◆ loadFromString()

XsensResultValue xsens::Message::loadFromString ( const uint8_t source,
const uint16_t  size 
)

◆ operator=()

void xsens::Message::operator= ( const Message src)

Copy message src into this.

Definition at line 699 of file cmtmessage.cpp.

References CMT_CHECKASSERT, m_buffer, m_checksum, m_maxLength, and mrpt::system::os::memcpy().

◆ recomputeChecksum()

void xsens::Message::recomputeChecksum ( void  )
inline

Compute the checksum field and fill it.

The checksum field should normally be correct at all times, but if you have somehow managed to mess it up, this function can be used to recompute it.

Definition at line 219 of file cmtmessage.h.

References calcChecksum(), and m_checksum.

Referenced by xsens::Cmt3::getConfiguration(), and resizeData().

◆ resizeData()

void xsens::Message::resizeData ( const uint16_t  newSize)

◆ setBusId()

void xsens::Message::setBusId ( const uint8_t  busId)

◆ setDataBuffer()

void xsens::Message::setDataBuffer ( const uint8_t data,
const uint16_t  offset = 0,
const uint16_t  count = 0 
)

Write a string of bytes into the data buffer.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.
countAn optional number of bytes to write, if set to 0 (not set), as many bytes as will fit into the buffer from the given point will be written.

Definition at line 471 of file cmtmessage.cpp.

References CMT_CHECKASSERT, getDataSize(), getDataStart(), m_autoUpdateChecksum, m_checksum, and resizeData().

Referenced by xsens::Cmt3::getEMtsData().

◆ setDataByte()

void xsens::Message::setDataByte ( const uint8_t  data,
const uint16_t  offset = 0 
)

◆ setDataDouble()

void xsens::Message::setDataDouble ( const double  data,
const uint16_t  offset = 0 
)

Write a double (64 bits) into the data buffer.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.

Definition at line 504 of file cmtmessage.cpp.

References CMT_CHECKASSERT, getDataSize(), getDataStart(), m_autoUpdateChecksum, m_checksum, and resizeData().

Referenced by setDataFPValue().

◆ setDataF1220()

void xsens::Message::setDataF1220 ( const double  data,
const uint16_t  offset = 0 
)

Write a double (64 bits) into the data buffer, after converting it to F1220.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.

Definition at line 544 of file cmtmessage.cpp.

References setDataLong(), and val.

Referenced by setDataFPValue().

◆ setDataFloat()

void xsens::Message::setDataFloat ( const float  data,
const uint16_t  offset = 0 
)

Write a float (32 bits) into the data buffer.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.

Definition at line 524 of file cmtmessage.cpp.

References CMT_CHECKASSERT, getDataSize(), getDataStart(), m_autoUpdateChecksum, m_checksum, and resizeData().

Referenced by setDataFPValue(), and xsens::Cmt3::setGpsLeverArm().

◆ setDataFP1632()

void xsens::Message::setDataFP1632 ( const double  data,
const uint16_t  offset = 0 
)

Write a double (64 bits) into the data buffer, after converting it to FP1632.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.

Definition at line 552 of file cmtmessage.cpp.

References CMT_CHECKASSERT, xsens::Itypes::d, getDataSize(), getDataStart(), xsens::Itypes::i0, xsens::Itypes::i1, xsens::Itypes::i16, xsens::Itypes::i32, xsens::Itypes::i64, resizeData(), xsens::Itypes::s0, and xsens::Itypes::s1.

Referenced by setDataFPValue().

◆ setDataFPValue() [1/2]

void xsens::Message::setDataFPValue ( const uint64_t  outputSettings,
const double  data,
const uint16_t  offset = 0 
)

◆ setDataFPValue() [2/2]

void xsens::Message::setDataFPValue ( const uint64_t  outputSettings,
const double *  data,
uint16_t  offset,
const uint16_t  numValues 
)

Write a floating/fixed point value into to the data buffer, conversion depends on outputSettings.

Parameters
outputSettingsMT output settings
dataThe data array to be written to the buffer.
offsetOffset in the data buffer from where to start writing.
numValuesnumber of values to be written

Definition at line 625 of file cmtmessage.cpp.

References CMT_OUTPUTSETTINGS_DATAFORMAT_DOUBLE, CMT_OUTPUTSETTINGS_DATAFORMAT_F1220, CMT_OUTPUTSETTINGS_DATAFORMAT_FLOAT, CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632, CMT_OUTPUTSETTINGS_DATAFORMAT_MASK, setDataDouble(), setDataF1220(), setDataFloat(), and setDataFP1632().

◆ setDataLong()

void xsens::Message::setDataLong ( const uint32_t  data,
const uint16_t  offset = 0 
)

Write an uint32_t (32 bits) into the data buffer.

Parameters
dataThe data to write to the buffer.
offsetAn optional offset in the data buffer from where to start writing.

Definition at line 653 of file cmtmessage.cpp.

References CMT_CHECKASSERT, getDataSize(), getDataStart(), m_autoUpdateChecksum, m_checksum, and resizeData().

Referenced by xsens::Cmt3::getConfiguration(), setDataF1220(), xsens::Cmt3::setDeviceMode2(), xsens::Cmt3::setSyncInOffset(), xsens::Cmt3::setSyncInSettings(), xsens::Cmt3::setSyncOutOffset(), xsens::Cmt3::setSyncOutPulseWidth(), xsens::Cmt3::setSyncOutSettings(), and xsens::Packet::updateRawGpsData().

◆ setDataShort()

void xsens::Message::setDataShort ( const uint16_t  data,
const uint16_t  offset = 0 
)

◆ setMessageId()

void xsens::Message::setMessageId ( const uint8_t  msgId)

Set the new value of the m_messageId field and update the checksum.

Definition at line 689 of file cmtmessage.cpp.

References CMT_CHECKASSERT, m_autoUpdateChecksum, m_buffer, m_checksum, and xsens::MessageHeader::m_messageId.

Referenced by xsens::Cmt3::refreshCache(), and xsens::Cmt3::setDeviceMode2().

Member Data Documentation

◆ m_autoUpdateChecksum

bool xsens::Message::m_autoUpdateChecksum

◆ m_buffer

CMT_CHECKVAR MessageHeader* xsens::Message::m_buffer
protected

The message header is the data buffer with interpretation.

Definition at line 81 of file cmtmessage.h.

Referenced by calcChecksum(), clear(), getBusId(), getDataSize(), getDataStart(), getMessageId(), getMessageStart(), getTotalMessageSize(), loadFromString(), Message(), operator=(), resizeData(), setBusId(), setMessageId(), and ~Message().

◆ m_checksum

uint8_t* xsens::Message::m_checksum
protected

◆ m_maxLength

uint32_t xsens::Message::m_maxLength
protected

The maximum size of the message, including header and footer.

Definition at line 85 of file cmtmessage.h.

Referenced by clear(), isChecksumOk(), loadFromString(), Message(), operator=(), and resizeData().




Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020