xsens::Message Class Reference

Class for storing a single message. More...

#include <Robots/SeaBeeIII/IMUDataServer/cmtmessage.h>

Collaboration diagram for xsens::Message:
Collaboration graph
[legend]

List of all members.

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

Public Attributes

bool m_autoUpdateChecksum

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Class for storing a single message.

Definition at line 76 of file cmtmessage.h.


Constructor & Destructor Documentation

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:
msgId The message Id that will be assigend to the m_messageId field.
length The length of the data in the message. This value is stored in m_createdLength as well as m_length or m_extendedLength.
maxLength The maximum data length that can be stored in the structure.

Definition at line 36 of file cmtmessage.cpp.

References m_buffer, m_checksum, and m_maxLength.

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:
source The source string containing message data
size The size of the source string
maxLength The maximum data length that can be stored in the structure.

Definition at line 73 of file cmtmessage.cpp.

References m_buffer, m_checksum, and m_maxLength.

xsens::Message::~Message (  ) 

Destructor.

Definition at line 117 of file cmtmessage.cpp.

References m_buffer.


Member Function Documentation

uint8_t xsens::Message::calcChecksum ( void   )  const [inline, protected]

Internal checksum computation.

Definition at line 87 of file cmtmessage.h.

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

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

void xsens::Message::clear ( void   ) 

Clear all data in the message.

Definition at line 125 of file cmtmessage.cpp.

References m_buffer, m_checksum, and m_maxLength.

Referenced by xsens::Cmt2f::readMessage(), and xsens::Cmt2s::waitForMessage().

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 693 of file cmtmessage.cpp.

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

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

Return the current value of the m_busId field.

Definition at line 127 of file cmtmessage.h.

References m_buffer.

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

Return a pointer to the data buffer.

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

Definition at line 132 of file cmtmessage.h.

References getDataStart().

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

uint8_t xsens::Message::getDataByte ( const uint16_t  offset = 0  )  const [inline]
double xsens::Message::getDataDouble ( const uint16_t  offset = 0  )  const

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

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

Definition at line 136 of file cmtmessage.cpp.

References getDataStart().

Referenced by getDataFPValue().

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:
offset An optional offset in the data buffer from where to start reading.

Definition at line 164 of file cmtmessage.cpp.

References getDataStart().

Referenced by getDataFPValue().

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

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

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

Definition at line 149 of file cmtmessage.cpp.

References getDataStart().

Referenced by getDataFPValue(), xsens::Cmt3::getHeading(), xsens::Cmt3::getLatLonAlt(), xsens::Cmt3::getMagneticDeclination(), and xsens::Cmt3::getObjectAlignmentMatrix().

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:
offset An optional offset in the data buffer from where to start reading.

Definition at line 200 of file cmtmessage.cpp.

References getDataStart().

Referenced by getDataFPValue().

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:
dest destination array
outputSettings MT output settings
offset offset in the data buffer from where to start reading.
numValues number of values to be read

Definition at line 249 of file cmtmessage.cpp.

References getDataDouble(), getDataF1220(), getDataFloat(), and getDataFP1632().

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

Return current data value as double, conversion depends on outputSettings.

Parameters:
outputSettings MT output settings
offset An optional offset in the data buffer from where to start reading.

Definition at line 227 of file cmtmessage.cpp.

References getDataDouble(), getDataF1220(), getDataFloat(), and getDataFP1632().

Referenced by xsens::Packet::getAccG(), xsens::Packet::getCalAcc(), xsens::Packet::getCalData(), xsens::Packet::getCalGyr(), xsens::Packet::getCalMag(), xsens::Packet::getOriEuler(), xsens::Packet::getOriMatrix(), xsens::Packet::getOriQuat(), xsens::Packet::getPositionLLA(), xsens::Packet::getTemp(), and xsens::Packet::getVelocity().

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:
offset An optional offset in the data buffer from where to start reading.

Definition at line 278 of file cmtmessage.cpp.

References getDataStart().

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

uint16_t xsens::Message::getDataShort ( const uint16_t  offset = 0  )  const
uint16_t xsens::Message::getDataSize ( void   )  const
uint8_t * xsens::Message::getDataStart ( void   )  const [protected]
uint8_t xsens::Message::getMessageId ( void   )  const [inline]
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 194 of file cmtmessage.h.

References m_buffer.

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

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 328 of file cmtmessage.cpp.

References m_buffer.

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

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 718 of file cmtmessage.cpp.

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

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

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

Definition at line 337 of file cmtmessage.cpp.

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

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

Read the entire message from the given source string.

This is done through a simple memory copy. The number of bytes copied is m_createdLength.

Parameters:
source The source string containing message data
size The size of the source string

Definition at line 346 of file cmtmessage.cpp.

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

Referenced by xsens::Cmt2f::readMessage(), xsens::Cmt2s::readMessage(), and xsens::Cmt2s::waitForMessage().

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

Copy message src into this.

Definition at line 678 of file cmtmessage.cpp.

References m_buffer, m_checksum, and m_maxLength.

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 218 of file cmtmessage.h.

References calcChecksum(), and m_checksum.

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

void xsens::Message::resizeData ( const uint16_t  newSize  ) 
void xsens::Message::setBusId ( const uint8_t  busId  ) 
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:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.
count An 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 459 of file cmtmessage.cpp.

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

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

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

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

Parameters:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 490 of file cmtmessage.cpp.

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

Referenced by setDataFPValue().

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:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 528 of file cmtmessage.cpp.

References setDataLong().

Referenced by setDataFPValue().

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

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

Parameters:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 509 of file cmtmessage.cpp.

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

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

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:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 536 of file cmtmessage.cpp.

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

Referenced by setDataFPValue().

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:
outputSettings MT output settings
data The data array to be written to the buffer.
offset Offset in the data buffer from where to start writing.
numValues number of values to be written

Definition at line 607 of file cmtmessage.cpp.

References setDataDouble(), setDataF1220(), setDataFloat(), and setDataFP1632().

void xsens::Message::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.

Parameters:
outputSettings MT output settings
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 588 of file cmtmessage.cpp.

References setDataDouble(), setDataF1220(), setDataFloat(), and setDataFP1632().

Referenced by xsens::Packet::updateAccG(), xsens::Packet::updateCalAcc(), xsens::Packet::updateCalData(), xsens::Packet::updateCalGyr(), xsens::Packet::updateCalMag(), xsens::Packet::updateOriEuler(), xsens::Packet::updateOriMatrix(), xsens::Packet::updateOriQuat(), xsens::Packet::updatePositionLLA(), xsens::Packet::updateTemp(), and xsens::Packet::updateVelocity().

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

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

Parameters:
data The data to write to the buffer.
offset An optional offset in the data buffer from where to start writing.

Definition at line 635 of file cmtmessage.cpp.

References getDataSize(), getDataStart(), 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(), xsens::Packet::updateGpsPvtData(), and xsens::Packet::updateUtcTime().

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

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

Definition at line 669 of file cmtmessage.cpp.

References m_buffer, and m_checksum.

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


Member Data Documentation

The message header is the data buffer with interpretation.

Definition at line 80 of file cmtmessage.h.

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

uint8_t* xsens::Message::m_checksum [protected]
uint32_t xsens::Message::m_maxLength [protected]

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

Definition at line 84 of file cmtmessage.h.

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


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:46 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3