10 #ifndef _CMTMESSAGE_H_2006_05_24
11 #define _CMTMESSAGE_H_2006_05_24
13 #ifndef _CMT_MONOLITHIC
59 #if defined(_DEBUG) && defined(_CMT_CHECK_MSG_DATA_INTEGRITY)
60 #define CMT_CHECKVAR uint32_t m_checkvar;
61 #define CMT_CHECKVAL 10101010
62 #define CMT_CHECKASSIGN m_checkvar = CMT_CHECKVAL;
63 #define CMT_CHECKASSERT if (m_checkvar != CMT_CHECKVAL) throw "Message assertion failed!";
67 #define CMT_CHECKASSIGN
68 #define CMT_CHECKASSERT
71 #define swapEndian16(src) (((src) >> 8) | ((src) << 8))
72 #define swapEndian32(src) (((src) >> 24) | ((src) >> 8 & 0xFF00) | ((src) << 8 & 0xFF0000) | ((src) << 24))
Class for storing a single message.
double getDataF1220(const uint16_t offset=0) const
Return the current value of the data as a double, converting it from FP 12.20.
bool m_autoUpdateChecksum
double getDataFPValue(const uint64_t outputSettings, const uint16_t offset=0) const
Return current data value as double, 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.
uint8_t getDataByte(const uint16_t offset=0) const
Return the current value of the data as an unsigned byte (8 bits).
CMT_CHECKVAR MessageHeader * m_buffer
The message header is the data buffer with interpretation.
uint32_t getDataLong(const uint16_t offset=0) const
Return the current value of the data as an uint32_t (32 bits).
void insertData(uint16_t size, uint16_t offset=0)
Insert a number of bytes into the message (this will increase the message size)
void deleteData(uint16_t size, uint16_t offset=0)
Remove a number of bytes from the message (this will reduce the message size)
uint8_t * getDataBuffer(const uint16_t offset=0)
Return a pointer to the data buffer.
uint8_t getBusId(void) const
Return the current value of the m_busId field.
uint16_t getTotalMessageSize(void) const
Return the length of the message buffer.
uint16_t getDataSize(void) const
Return the length of the data part of the message.
uint16_t getDataShort(const uint16_t offset=0) const
Return the current value of the data as an uint16_t (16 bits).
void setDataFloat(const float data, const uint16_t offset=0)
Write a float (32 bits) into the data buffer.
void setDataFP1632(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer, after converting it to FP1632.
uint8_t getMessageId(void) const
Return the current value of the m_messageId field.
uint8_t calcChecksum(void) const
Internal checksum computation.
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.
bool isChecksumOk(void) const
Compute the checksum and compare it with the stored checksum. Equal is ok.
void setDataShort(const uint16_t data, const uint16_t offset=0)
Write an uint16_t (16 bits) into the data buffer.
float getDataFloat(const uint16_t offset=0) const
Return the current value of the data as a float (32 bits).
uint8_t * m_checksum
The checksum in the m_data or m_extendedData buffer.
void clear(void)
Clear all data in the message.
void setBusId(const uint8_t busId)
Set the new value of the m_busId field and update the checksum.
void setDataF1220(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer, after converting it to F1220.
uint32_t m_maxLength
The maximum size of the message, including header and footer.
double getDataDouble(const uint16_t offset=0) const
Return the current value of the data as a double (64 bits).
void setMessageId(const uint8_t msgId)
Set the new value of the m_messageId field and update the checksum.
uint8_t * getDataStart(void) const
Internal function to get the start of the data buffer.
void setDataDouble(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer.
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.
double getDataFP1632(const uint16_t offset=0) const
Return the current value of the data as a double, converting it from FP 16.32.
const uint8_t * getMessageStart(void) const
Return the start of the message buffer.
void operator=(const Message &src)
Copy message src into this.
XsensResultValue loadFromString(const uint8_t *source, const uint16_t size)
Read the entire message from the given source string.
const uint8_t * getDataBuffer(const uint16_t offset=0) const
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.
void recomputeChecksum(void)
Compute the checksum field and fill it.
void resizeData(const uint16_t newSize)
Resize the data area to the given size.
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLsizei GLsizei * length
GLuint GLuint GLsizei count
GLsizei GLsizei GLchar * source
The namespace of all Xsens software since 2006.
uint8_t computeChecksum(const uint8_t *buffer, uint32_t length)
Compute the checksum of the given byte string.
unsigned __int16 uint16_t
unsigned __int32 uint32_t
unsigned __int64 uint64_t
XsensResultValue
Xsens return values.