Main MRPT website > C++ reference for MRPT 1.5.9
cmtmessage.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 /*! \file Cmtmessage.cpp
11 
12  For information about objects in this file, see the appropriate header:
13  \ref Cmtmessage.h
14 
15  \section FileCopyright Copyright Notice
16  Copyright (C) Xsens Technologies B.V., 2006. All rights reserved.
17 
18  This source code is intended for use only by Xsens Technologies BV and
19  those that have explicit written permission to use it from
20  Xsens Technologies BV.
21 
22  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
23  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
25  PARTICULAR PURPOSE.
26 
27 */
28 
29 #include "cmtmessage.h"
30 
31 namespace xsens {
32 
33 #ifdef _LOG_CMT_MSG
34 #define MSGLOG CMTLOG
35 #else
36 #define MSGLOG(...)
37 #endif
38 
39 //////////////////////////////////////////////////////////////////////////////////////////
40 // Create a Message object with the given data length and message Id.
42 {
44 
47  else
49  m_buffer = (MessageHeader*) new char[m_maxLength];//(MessageHeader*) malloc(m_maxLength);
50  MSGLOG("Message(%02x, %hu, %hu): buffer = %p\n",(int32_t) msgId, length, m_maxLength,m_buffer);
51  memset(m_buffer,0,m_maxLength);
52 
54  m_buffer->m_messageId = msgId;
56 
57  if (length >= 255)
58  {
60 
63 
65  m_checksum[0] = -(msgId + CMT_EXTLENCODE + (uint8_t)length + (length >> 8));
66  }
67  else
68  {
71  m_checksum[0] = -(msgId + (uint8_t) length);
72  }
74 
75  m_autoUpdateChecksum = true;
76 }
77 
78 //////////////////////////////////////////////////////////////////////////////////////////
79 // Create a message from the given source string
81 {
83 
84  const MessageHeader* tmp = (MessageHeader*) source;
86 
89  else
91 
92  if (tmp->m_length == CMT_EXTLENCODE)
93  length = ((uint16_t) tmp->m_datlen.m_extended.m_length.m_high * 256 + (uint16_t) tmp->m_datlen.m_extended.m_length.m_low) + CMT_LEN_MSGEXTHEADERCS;
94  else
95  length = tmp->m_length + CMT_LEN_MSGHEADERCS;
96  if (size && size < length)
97  length = size;
98 
99  if ((uint32_t) length > m_maxLength)
101 
102  m_buffer = (MessageHeader*) new char[m_maxLength];//(MessageHeader*) malloc(m_maxLength);
103  MSGLOG("Message(%02x%02x%02x%02x%02x%02x, %hu, %hu): buffer = %p\n",source[0],source[1],source[2],source[3],source[4],source[5], size, m_maxLength,m_buffer);
104  if (length < m_maxLength)
105  memset(&(((uint8_t*) m_buffer)[length]),0,m_maxLength-length);
106 
108 
109  m_checksum = &(((uint8_t*) m_buffer)[length-1]);
110 
111  m_autoUpdateChecksum = true;
112 }
113 
115 {
117 
118  m_maxLength = src.m_maxLength;
119  m_buffer = (MessageHeader*) new char[m_maxLength];
120  memcpy(m_buffer,src.m_buffer,m_maxLength);
121  ptrdiff_t add = (uint8_t*) src.m_checksum - (uint8_t*) src.m_buffer;
122  m_checksum = (uint8_t*) m_buffer + add;
123  m_autoUpdateChecksum = true;
124 }
125 
126 //////////////////////////////////////////////////////////////////////////////////////////
127 // Destroy a Message object.
129 {
131  MSGLOG("~Message(): buffer = %p\n",m_buffer);
132  CHKDELNUL(m_buffer);//free(m_buffer);
133 }
134 
135 //////////////////////////////////////////////////////////////////////////////////////////
136 // Clear all data in the message
137 void Message::clear(void)
138 {
140 
141  memset(m_buffer,0,m_maxLength);
146 }
147 
148 //////////////////////////////////////////////////////////////////////////////////////////
149 // Return the current value of the data as a double (64 bits).
151 {
153  double ret;
154  uint8_t* dest = (uint8_t*) &ret;
155  uint8_t* src = &(getDataStart()[offset]);
156  dest[0] = src[7]; dest[1] = src[6]; dest[2] = src[5]; dest[3] = src[4];
157  dest[4] = src[3]; dest[5] = src[2]; dest[6] = src[1]; dest[7] = src[0];
158 
159  return ret;
160 }
161 
162 //////////////////////////////////////////////////////////////////////////////////////////
163 // Return the current value of the data as a float (32 bits).
165 {
167  float ret;
168  uint8_t* dest = (uint8_t*) &ret;
169  uint8_t* src = &(getDataStart()[offset]);
170  dest[0] = src[3];
171  dest[1] = src[2];
172  dest[2] = src[1];
173  dest[3] = src[0];
174 
175  return ret;
176 }
177 
178 //////////////////////////////////////////////////////////////////////////////////////////
179 // Return the current value of the data as a double(64 bits), after converting it from F1220.
181 {
183  double ret;
184  int32_t tmp;
185  uint8_t* dest = (uint8_t*) &tmp;
186  uint8_t* src = &(getDataStart()[offset]);
187  dest[0] = src[3];
188  dest[1] = src[2];
189  dest[2] = src[1];
190  dest[3] = src[0];
191 
192  ret = ((double) tmp)/1048576.0;
193  return ret;
194 }
195 
196 // little endian
197 union Itypes {
199  struct {
201  } i32;
202  struct {
204  } i16;
205  struct {
206  signed char b7,b6,b5,b4,b3,b2,b1,b0;
207  } i8;
208 
209  double d;
210  struct {
211  float f1,f0;
212  } f32;
213 };
214 
215 //////////////////////////////////////////////////////////////////////////////////////////
216 // Return the current value of the data as a double(64 bits), after converting it from FP1632.
218 {
220 
221  int16_t fpint;
222  int32_t fpfrac;
223 
224  uint8_t* dest = (uint8_t*) &fpfrac;
225  uint8_t* src = &(getDataStart()[offset]);
226  dest[3] = *(src++);
227  dest[2] = *(src++);
228  dest[1] = *(src++);
229  dest[0] = *(src++);
230 
231  dest = (uint8_t*) &fpint;
232  dest[1] = *(src++);
233  dest[0] = *(src++);
234 
235  Itypes fp;
236  fp.i32.i0 = fpint;
237  fp.i32.i1 = fpfrac;
238 
239  return (double) fp.i64 / 4294967296.0;
240 }
241 
242 //////////////////////////////////////////////////////////////////////////////////////////
243 // Return current data value as a double(64 bits), after converting it from
244 // float, double, FP1632 or FP1220 depending on outputSettings
245 double Message::getDataFPValue(const uint64_t outputSettings, const uint16_t offset) const
246 {
247  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
248  {
250  return getDataFloat(offset);
251 
253  return getDataDouble(offset);
254 
256  return getDataFP1632(offset);
257 
259  return getDataF1220(offset);
260  }
261  return 0.0; // should never happen
262 }
263 
264 //////////////////////////////////////////////////////////////////////////////////////////
265 // Return current data values as a double(64 bits), after converting it from
266 // float, double, FP1632 or FP1220 depending on outputSettings
267 void Message::getDataFPValue(double *dest, const uint64_t outputSettings, uint16_t offset, const int16_t numValues) const
268 {
269  for (uint16_t i=0; i<numValues; i++) {
270  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
271  {
273  *dest++ = getDataFloat(offset);
274  offset += 4;
275  break;
276 
278  *dest++ = getDataDouble(offset);
279  offset += 8;
280  break;
281 
283  *dest++ = getDataFP1632(offset);
284  offset += 6;
285  break;
286 
288  *dest++ = getDataF1220(offset);
289  offset += 4;
290  }
291  }
292 }
293 
294 //////////////////////////////////////////////////////////////////////////////////////////
295 // Return the current value of the data as an uint32_t (32 bits).
297 {
299  uint32_t ret;
300  uint8_t* dest = (uint8_t*) &ret;
301  uint8_t* src = &(getDataStart()[offset]);
302  dest[0] = src[3];
303  dest[1] = src[2];
304  dest[2] = src[1];
305  dest[3] = src[0];
306 
307  return ret;
308 }
309 
310 //////////////////////////////////////////////////////////////////////////////////////////
311 // Return the current value of the data as an uint16_t (16 bits).
313 {
315  uint16_t ret;
316  uint8_t* dest = (uint8_t*) &ret;
317  uint8_t* src = &(getDataStart()[offset]);
318  dest[0] = src[1];
319  dest[1] = src[0];
320 
321  return ret;
322 }
323 
324 //////////////////////////////////////////////////////////////////////////////////////////
325 // Return the length of the message buffer.
327 {
329  if (m_buffer->m_length == 255)
331  else
332  return m_buffer->m_length;
333 }
334 
335 //////////////////////////////////////////////////////////////////////////////////////////
336 // Internal function to get the start of the data buffer.
338 {
340  if (m_buffer->m_length == 255)
341  {
342  return const_cast<uint8_t*>(m_buffer->m_datlen.m_extended.m_data);
343  }
344  else
345  return const_cast<uint8_t*>(m_buffer->m_datlen.m_data);
346 }
347 
348 //////////////////////////////////////////////////////////////////////////////////////////
349 // Return the length of the message buffer.
351 {
353  if (m_buffer->m_length == 255)
355  else
357 }
358 
359 //////////////////////////////////////////////////////////////////////////////////////////
360 bool Message::isChecksumOk(void) const
361 {
363  return false;
364  return calcChecksum() == m_checksum[0];
365 }
366 
367 //////////////////////////////////////////////////////////////////////////////////////////
368 // Read the entire message from the given source string
370 {
372  if (size > m_maxLength)
373  return XRV_PARAMINVALID;
375  m_checksum = ((uint8_t*) m_buffer) + size-1;
376  // check the size
378  {
380  return XRV_DATACORRUPT;
381  }
382  else
383  {
385  return XRV_DATACORRUPT;
386  }
387 
388  if (m_checksum[0] != calcChecksum())
389  return XRV_CHECKSUMFAULT;
390  return XRV_OK;
391 }
392 
393 //////////////////////////////////////////////////////////////////////////////////////////
394 void Message::resizeData(const uint16_t newSize)
395 {
397  int32_t index, oldLength;
398 
399  MSGLOG("Message.resizeData(%hu): buffer = %p\n",newSize,m_buffer);
400 
401  if ((uint32_t) (newSize + CMT_LEN_MSGEXTHEADERCS) > m_maxLength)
402  {
404  if ((newSize + CMT_LEN_MSGEXTHEADERCS) > newLen)
405  newLen = newSize + CMT_LEN_MSGEXTHEADERCS;
406  m_buffer = (MessageHeader*) realloc(m_buffer,newLen);
407  m_maxLength = newLen;
408  }
409 
410  MSGLOG("Message.resizeData after realloc(%hu): buffer = %p\n",m_maxLength,m_buffer);
411 
412  if (newSize >= CMT_EXTLENCODE)
413  {
415  {
416  // make extended, shift all data 2 bytes up
417  for (index = (int32_t) m_buffer->m_length; index >= 0; --index)
420 
421  oldLength = m_buffer->m_length;
423  }
424  else
425  {
427  }
428  m_buffer->m_datlen.m_extended.m_length.m_high = (uint8_t) (newSize >> 8);
430 
431  for (index = oldLength; index < newSize; ++index)
433 
435  }
436  else
437  {
439  {
441  // un-extend, shift all data 2 bytes down
442  for (index = 0; index < newSize; ++index)
445  }
446  else
447  oldLength = m_buffer->m_length;
448  m_buffer->m_length = (uint8_t) newSize;
449  for (index = oldLength; index < newSize; ++index)
451  m_checksum = &m_buffer->m_datlen.m_data[newSize];
452  }
455  MSGLOG("Message.resizeData end(%hu): buffer = %p\n",m_maxLength,m_buffer);
457 }
458 
459 //////////////////////////////////////////////////////////////////////////////////////////
460 // Set the new value of the m_busId field and update the checksum.
461 void Message::setBusId(const uint8_t busId)
462 {
465  m_checksum[0] += m_buffer->m_busId - busId;
466  m_buffer->m_busId = busId;
467 }
468 
469 //////////////////////////////////////////////////////////////////////////////////////////
470 // Write a string of bytes into the data buffer.
472  const uint16_t count)
473 {
475  if (getDataSize() < offset+count)
477 
478  if (count > 0)
479  {
480  uint8_t * dest = &(getDataStart()[offset]);
481  for (uint16_t i = 0;i < count;++i)
482  {
484  m_checksum[0] += dest[i] - data[i];
485  dest[i] = data[i];
486  }
487  }
488 }
489 
490 //////////////////////////////////////////////////////////////////////////////////////////
492 {
494  if (getDataSize() < offset + 1)
495  resizeData(offset+1);
496 
497  uint8_t* dest = &(getDataStart()[offset]);
499  m_checksum[0] += dest[0] - data;
500  dest[0] = data;
501 }
502 
503 //////////////////////////////////////////////////////////////////////////////////////////
504 void Message::setDataDouble(const double data, const uint16_t offset)
505 {
507  if (getDataSize() < offset+8)
508  resizeData(offset+8);
509 
510  uint8_t* dest = &(getDataStart()[offset]);
511  const uint8_t* cdata = (const uint8_t*) &data;
513  m_checksum[0] += dest[0] + dest[1] + dest[2] + dest[3]
514  + dest[4] + dest[5] + dest[6] + dest[7]
515  - cdata[0] - cdata[1] - cdata[2] - cdata[3]
516  - cdata[4] - cdata[5] - cdata[6] - cdata[7];
517 
518  const uint8_t* src = (const uint8_t*) &data;
519  dest[0] = src[7]; dest[1] = src[6]; dest[2] = src[5]; dest[3] = src[4];
520  dest[4] = src[3]; dest[5] = src[2]; dest[6] = src[1]; dest[7] = src[0];
521 }
522 
523 //////////////////////////////////////////////////////////////////////////////////////////
524 void Message::setDataFloat(const float data, const uint16_t offset)
525 {
527  if (getDataSize() < offset+4)
528  resizeData(offset+4);
529 
530  uint8_t* dest = &(getDataStart()[offset]);
531  const uint8_t* cdata = (const uint8_t*) &data;
533  m_checksum[0] += dest[0] + dest[1] + dest[2] + dest[3]
534  - cdata[0] - cdata[1] - cdata[2] - cdata[3];
535 
536  const uint8_t* src = (const uint8_t*) &data;
537  dest[0] = src[3];
538  dest[1] = src[2];
539  dest[2] = src[1];
540  dest[3] = src[0];
541 }
542 
543 //////////////////////////////////////////////////////////////////////////////////////////
544 void Message::setDataF1220(const double data, const uint16_t offset)
545 {
546  int32_t val = (int32_t) (data*1048576.0);
548 }
549 
550 //////////////////////////////////////////////////////////////////////////////////////////
551 // Return the current value of the data as a double(64 bits), after converting it from F1220.
552 void Message::setDataFP1632(const double data, const uint16_t offset)
553 {
555 
556  if (getDataSize() < offset+6)
557  resizeData(offset+6);
558 
559  Itypes fp;
560  fp.d = data;
561  int32_t dexp = ((fp.i32.i0 & (0x7fffffffL)) >> 20) - 1023;
562 
563  int16_t fpint;
564  int32_t fpfrac;
565 
566  if (dexp <= 14)
567  {
568  fp.i16.s0 = (fp.i16.s0 & 0x000F) | 0x0010;
569  if (data < 0)
570  fp.i64 = -fp.i64;
571  if (dexp > -32)
572  fp.i64 = fp.i64 >> (20-dexp); // 52-32 - exponent
573  else
574  fp.i64 = fp.i64 >> 52; // this could be optimized?
575  fpint = fp.i16.s1;
576  fpfrac = fp.i32.i1;
577  }
578  else
579  {
580  if (data < 0)
581  {
582  fpint = ((int16_t) (0x8000));
583  fpfrac = 0;
584  }
585  else
586  {
587  fpint = 0x7fff;
588  fpfrac = -1;
589  }
590  }
591 
592  uint8_t* src = (uint8_t*) &fpfrac;
593  uint8_t* dest = &(getDataStart()[offset]);
594 
595  *(dest++) = src[3];
596  *(dest++) = src[2];
597  *(dest++) = src[1];
598  *(dest++) = src[0];
599 
600  src = (uint8_t*) &fpint;
601  *(dest++) = src[1];
602  *(dest++) = src[0];
603 }
604 
605 //////////////////////////////////////////////////////////////////////////////////////////
606 void Message::setDataFPValue(const uint64_t outputSettings, const double data, const uint16_t offset)
607 {
608  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
609  {
611  return setDataFloat((const float)data, offset);
612 
614  return setDataDouble(data, offset);
615 
617  return setDataFP1632(data, offset);
618 
620  return setDataF1220(data, offset);
621  }
622 }
623 
624 //////////////////////////////////////////////////////////////////////////////////////////
625 void Message::setDataFPValue(const uint64_t outputSettings, const double *data, uint16_t offset, const uint16_t numValues)
626 {
627  for (uint16_t i=0; i<numValues; i++) {
628  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
629  {
631  setDataFloat((float)data[i], offset);
632  offset += 4;
633  break;
634 
637  offset += 8;
638  break;
639 
642  offset += 6;
643  break;
644 
646  setDataF1220(data[i], offset);
647  offset += 4;
648  }
649  }
650 }
651 
652 //////////////////////////////////////////////////////////////////////////////////////////
654 {
656  if (getDataSize() < offset+4)
657  resizeData(offset+4);
658 
659  uint8_t* dest = &(getDataStart()[offset]);
661  m_checksum[0] +=(uint8_t)(dest[0] + dest[1] + dest[2] + dest[3] - (data & 0xFF)-
662  ((data >> 8) & 0xFF) - ((data >> 16) & 0xFF) - ((data >> 24) & 0xFF));
663 
664  const uint8_t* src = (const uint8_t*) &data;
665  dest[0] = src[3];
666  dest[1] = src[2];
667  dest[2] = src[1];
668  dest[3] = src[0];
669 }
670 
671 //////////////////////////////////////////////////////////////////////////////////////////
673 {
675  if (getDataSize() < offset+2)
676  resizeData(offset+2);
677 
678  uint8_t* dest = &(getDataStart()[offset]);
680  m_checksum[0] += dest[0] + dest[1] - (data & 255) - (data >> 8);
681 
682  const uint8_t* src = (const uint8_t*) &data;
683  dest[0] = src[1];
684  dest[1] = src[0];
685 }
686 
687 //////////////////////////////////////////////////////////////////////////////////////////
688 // Set the new value of the m_messageId field and update the checksum.
690 {
693  m_checksum[0] += m_buffer->m_messageId - msgId;
694  m_buffer->m_messageId =msgId;
695 }
696 
697 //////////////////////////////////////////////////////////////////////////////////////////
698 // Copy message src into this
700 {
702 
703  if (m_maxLength != src.m_maxLength)
704  {
705  CHKDELNUL(m_buffer);
706  m_maxLength = src.m_maxLength;
707  m_buffer = (MessageHeader*) new char[m_maxLength];
708  }
709  memcpy(m_buffer,src.m_buffer,m_maxLength);
710  ptrdiff_t add = (uint8_t*) src.m_checksum - (uint8_t*) src.m_buffer;
711  m_checksum = (uint8_t*) m_buffer + add;
712 }
713 
714 //////////////////////////////////////////////////////////////////////////////////////////
715 // Remove a number of bytes from the message (this will reduce the message size)
717 {
718  if (size == 0)
719  return;
720  uint16_t oldSize = getDataSize();
721  uint16_t newSize;
722  if (offset >= oldSize)
723  return;
724 
725  if (oldSize > offset + size)
726  newSize = oldSize - size;
727  else
728  newSize = offset;
729 
730  // shift all bytes after the offset down by size positions
732  for (uint16_t i = offset; i < newSize; ++i)
733  address[i] = address[i+size];
734 
735  // reduce the message length
736  resizeData(newSize);
737 }
738 
739 //////////////////////////////////////////////////////////////////////////////////////////
740 // Insert a number of bytes into the message (this will increase the message size)
742 {
743  if (size == 0)
744  return;
745  // stretch the message
746  uint16_t oldSize = getDataSize();
747  resizeData(oldSize + size);
748  // shift the bytes after the offset up by size positions
750  for (uint16_t i = oldSize-1; i >= offset && i < oldSize; --i)
751  address[i+size] = address[i];
752 }
753 
754 //////////////////////////////////////////////////////////////////////////////////////////
755 // Compute the checksum of the given byte string.
757 {
758  uint8_t cs = 0;
759  while (length--)
760  cs -= *(buffer++);
761 
762  return cs;
763 }
764 
765 } // end of xsens namespace
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
Definition: os.cpp:358
#define CMT_OUTPUTSETTINGS_DATAFORMAT_FLOAT
Definition: cmtdef.h:636
uint32_t getDataLong(const uint16_t offset=0) const
Return the current value of the data as an uint32_t (32 bits).
Definition: cmtmessage.cpp:296
Operation was performed successfully.
Definition: xsens_std.h:32
#define CMT_CHECKASSERT
Definition: cmtmessage.h:68
double getDataFPValue(const uint64_t outputSettings, const uint16_t offset=0) const
Return current data value as double, conversion depends on outputSettings.
Definition: cmtmessage.cpp:245
A message header.
Definition: cmtmessage.h:35
GLuint GLuint GLsizei count
Definition: glext.h:3512
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...
Definition: cmtmessage.cpp:606
signed char b4
Definition: cmtmessage.cpp:206
signed char b1
Definition: cmtmessage.cpp:206
signed char b6
Definition: cmtmessage.cpp:206
#define CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632
Definition: cmtdef.h:638
unsigned __int16 uint16_t
Definition: rptypes.h:46
uint8_t * getDataStart(void) const
Internal function to get the start of the data buffer.
Definition: cmtmessage.cpp:337
#define CMT_CHECKASSIGN
Definition: cmtmessage.h:67
uint8_t m_data[CMT_MAXDATALEN]
Definition: cmtmessage.h:46
struct xsens::Itypes::@91 i32
struct xsens::Itypes::@94 f32
void resizeData(const uint16_t newSize)
Resize the data area to the given size.
Definition: cmtmessage.cpp:394
void operator=(const Message &src)
Copy message src into this.
Definition: cmtmessage.cpp:699
GLuint buffer
Definition: glext.h:3775
double getDataFP1632(const uint16_t offset=0) const
Return the current value of the data as a double, converting it from FP 16.32.
Definition: cmtmessage.cpp:217
void deleteData(uint16_t size, uint16_t offset=0)
Remove a number of bytes from the message (this will reduce the message size)
Definition: cmtmessage.cpp:716
GLintptr offset
Definition: glext.h:3780
double getDataF1220(const uint16_t offset=0) const
Return the current value of the data as a double, converting it from FP 12.20.
Definition: cmtmessage.cpp:180
#define CMT_MAXMSGLEN
Definition: cmtdef.h:75
void clear(void)
Clear all data in the message.
Definition: cmtmessage.cpp:137
uint16_t getDataSize(void) const
Return the length of the data part of the message.
Definition: cmtmessage.cpp:326
void insertData(uint16_t size, uint16_t offset=0)
Insert a number of bytes into the message (this will increase the message size)
Definition: cmtmessage.cpp:741
An invalid parameter is supplied.
Definition: xsens_std.h:52
GLuint src
Definition: glext.h:6303
~Message()
Destructor.
Definition: cmtmessage.cpp:128
#define CMT_OUTPUTSETTINGS_DATAFORMAT_DOUBLE
Definition: cmtdef.h:639
uint16_t getDataShort(const uint16_t offset=0) const
Return the current value of the data as an uint16_t (16 bits).
Definition: cmtmessage.cpp:312
signed char b7
Definition: cmtmessage.cpp:206
void recomputeChecksum(void)
Compute the checksum field and fill it.
Definition: cmtmessage.h:219
#define CMT_LEN_MSGEXTHEADER
Definition: cmtdef.h:64
unsigned char uint8_t
Definition: rptypes.h:43
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.
Definition: cmtmessage.cpp:41
#define MSGLOG(...)
Definition: cmtmessage.cpp:36
CMT_CHECKVAR MessageHeader * m_buffer
The message header is the data buffer with interpretation.
Definition: cmtmessage.h:81
uint8_t computeChecksum(const uint8_t *buffer, uint32_t length)
Compute the checksum of the given byte string.
Definition: cmtmessage.cpp:756
__int16 int16_t
Definition: rptypes.h:45
Checksum fault occured.
Definition: xsens_std.h:62
float getDataFloat(const uint16_t offset=0) const
Return the current value of the data as a float (32 bits).
Definition: cmtmessage.cpp:164
__int64 int64_t
Definition: rptypes.h:51
GLuint index
Definition: glext.h:3891
A trusted data stream proves to contain corrupted data.
Definition: xsens_std.h:80
XsensResultValue
Xsens return values.
Definition: xsens_std.h:30
int val
Definition: mrpt_jpeglib.h:953
#define CMT_LEN_MSGEXTHEADERCS
Definition: cmtdef.h:66
void setDataFloat(const float data, const uint16_t offset=0)
Write a float (32 bits) into the data buffer.
Definition: cmtmessage.cpp:524
signed char b5
Definition: cmtmessage.cpp:206
XsensResultValue loadFromString(const uint8_t *source, const uint16_t size)
Read the entire message from the given source string.
Definition: cmtmessage.cpp:369
#define CMT_OUTPUTSETTINGS_DATAFORMAT_MASK
Definition: cmtdef.h:653
void setDataLong(const uint32_t data, const uint16_t offset=0)
Write an uint32_t (32 bits) into the data buffer.
Definition: cmtmessage.cpp:653
#define CMT_PREAMBLE
Definition: cmtdef.h:58
_W64 int ptrdiff_t
Definition: glew.h:133
#define CMT_EXTLENCODE
Definition: cmtdef.h:61
void setDataDouble(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer.
Definition: cmtmessage.cpp:504
uint8_t * getDataBuffer(const uint16_t offset=0)
Return a pointer to the data buffer.
Definition: cmtmessage.h:133
__int32 int32_t
Definition: rptypes.h:48
unsigned __int64 uint64_t
Definition: rptypes.h:52
signed char b0
Definition: cmtmessage.cpp:206
struct xsens::MessageHeader::_mdl::_mextd m_extended
#define CMT_OUTPUTSETTINGS_DATAFORMAT_F1220
Definition: cmtdef.h:637
void setDataFP1632(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer, after converting it to FP1632.
Definition: cmtmessage.cpp:552
uint8_t calcChecksum(void) const
Internal checksum computation.
Definition: cmtmessage.h:88
#define CMT_LEN_MSGHEADERCS
Definition: cmtdef.h:65
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
GLsizei GLsizei GLchar * source
Definition: glext.h:3908
signed char b3
Definition: cmtmessage.cpp:206
GLuint address
Definition: glext.h:6078
The namespace of all Xsens software since 2006.
Definition: cmt1.cpp:92
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.
Definition: cmtmessage.cpp:471
signed char b2
Definition: cmtmessage.cpp:206
GLsizei maxLength
Definition: glext.h:4504
#define CMT_LEN_MSGHEADER
Definition: cmtdef.h:63
void setMessageId(const uint8_t msgId)
Set the new value of the m_messageId field and update the checksum.
Definition: cmtmessage.cpp:689
void setBusId(const uint8_t busId)
Set the new value of the m_busId field and update the checksum.
Definition: cmtmessage.cpp:461
GLsizeiptr size
Definition: glext.h:3779
struct xsens::MessageHeader::_mdl::_mextd::_mlen m_length
struct xsens::Itypes::@93 i8
bool m_autoUpdateChecksum
Definition: cmtmessage.h:94
uint16_t getTotalMessageSize(void) const
Return the length of the message buffer.
Definition: cmtmessage.cpp:350
unsigned __int32 uint32_t
Definition: rptypes.h:49
bool isChecksumOk(void) const
Compute the checksum and compare it with the stored checksum. Equal is ok.
Definition: cmtmessage.cpp:360
uint8_t * m_checksum
The checksum in the m_data or m_extendedData buffer.
Definition: cmtmessage.h:83
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
#define CMT_BID_MASTER
Definition: cmtdef.h:59
double getDataDouble(const uint16_t offset=0) const
Return the current value of the data as a double (64 bits).
Definition: cmtmessage.cpp:150
void setDataF1220(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer, after converting it to F1220.
Definition: cmtmessage.cpp:544
struct xsens::Itypes::@92 i16
void setDataByte(const uint8_t data, const uint16_t offset=0)
Write an unsigned byte (8 bits) into the data buffer.
Definition: cmtmessage.cpp:491
uint32_t m_maxLength
The maximum size of the message, including header and footer.
Definition: cmtmessage.h:85
Class for storing a single message.
Definition: cmtmessage.h:76
union xsens::MessageHeader::_mdl m_datlen
void setDataShort(const uint16_t data, const uint16_t offset=0)
Write an uint16_t (16 bits) into the data buffer.
Definition: cmtmessage.cpp:672



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