MRPT  1.9.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-2018, 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  const uint8_t msgId, const uint16_t length, const uint16_t maxLength)
43 {
45 
48  else
50  m_buffer = (MessageHeader*)new char[m_maxLength]; //(MessageHeader*)
51  // malloc(m_maxLength);
52  MSGLOG(
53  "Message(%02x, %hu, %hu): buffer = %p\n", (int32_t)msgId, length,
55  memset(m_buffer, 0, m_maxLength);
56 
58  m_buffer->m_messageId = msgId;
60 
61  if (length >= 255)
62  {
64 
67 
69  m_checksum[0] =
70  -(msgId + CMT_EXTLENCODE + (uint8_t)length + (length >> 8));
71  }
72  else
73  {
76  m_checksum[0] = -(msgId + (uint8_t)length);
77  }
79 
80  m_autoUpdateChecksum = true;
81 }
82 
83 //////////////////////////////////////////////////////////////////////////////////////////
84 // Create a message from the given source string
86  const uint8_t* source, const uint16_t size, const uint16_t maxLength)
87 {
89 
90  const MessageHeader* tmp = (MessageHeader*)source;
92 
95  else
97 
98  if (tmp->m_length == CMT_EXTLENCODE)
99  length = ((uint16_t)tmp->m_datlen.m_extended.m_length.m_high * 256 +
100  (uint16_t)tmp->m_datlen.m_extended.m_length.m_low) +
102  else
103  length = tmp->m_length + CMT_LEN_MSGHEADERCS;
104  if (size && size < length) length = size;
105 
107 
108  m_buffer = (MessageHeader*)new char[m_maxLength]; //(MessageHeader*)
109  // malloc(m_maxLength);
110  MSGLOG(
111  "Message(%02x%02x%02x%02x%02x%02x, %hu, %hu): buffer = %p\n", source[0],
112  source[1], source[2], source[3], source[4], source[5], size,
114  if (length < m_maxLength)
115  memset(&(((uint8_t*)m_buffer)[length]), 0, m_maxLength - length);
116 
118 
119  m_checksum = &(((uint8_t*)m_buffer)[length - 1]);
120 
121  m_autoUpdateChecksum = true;
122 }
123 
125 {
127 
128  m_maxLength = src.m_maxLength;
129  m_buffer = (MessageHeader*)new char[m_maxLength];
130  memcpy(m_buffer, src.m_buffer, m_maxLength);
131  ptrdiff_t add = (uint8_t*)src.m_checksum - (uint8_t*)src.m_buffer;
132  m_checksum = (uint8_t*)m_buffer + add;
133  m_autoUpdateChecksum = true;
134 }
135 
136 //////////////////////////////////////////////////////////////////////////////////////////
137 // Destroy a Message object.
139 {
141  MSGLOG("~Message(): buffer = %p\n", m_buffer);
142  CHKDELNUL(m_buffer); // free(m_buffer);
143 }
144 
145 //////////////////////////////////////////////////////////////////////////////////////////
146 // Clear all data in the message
147 void Message::clear(void)
148 {
150 
151  memset(m_buffer, 0, m_maxLength);
156 }
157 
158 //////////////////////////////////////////////////////////////////////////////////////////
159 // Return the current value of the data as a double (64 bits).
161 {
163  double ret;
164  uint8_t* dest = (uint8_t*)&ret;
165  uint8_t* src = &(getDataStart()[offset]);
166  dest[0] = src[7];
167  dest[1] = src[6];
168  dest[2] = src[5];
169  dest[3] = src[4];
170  dest[4] = src[3];
171  dest[5] = src[2];
172  dest[6] = src[1];
173  dest[7] = src[0];
174 
175  return ret;
176 }
177 
178 //////////////////////////////////////////////////////////////////////////////////////////
179 // Return the current value of the data as a float (32 bits).
181 {
183  float ret;
184  uint8_t* dest = (uint8_t*)&ret;
185  uint8_t* src = &(getDataStart()[offset]);
186  dest[0] = src[3];
187  dest[1] = src[2];
188  dest[2] = src[1];
189  dest[3] = src[0];
190 
191  return ret;
192 }
193 
194 //////////////////////////////////////////////////////////////////////////////////////////
195 // Return the current value of the data as a double(64 bits), after converting
196 // it from F1220.
198 {
200  double ret;
201  int32_t tmp;
202  uint8_t* dest = (uint8_t*)&tmp;
203  uint8_t* src = &(getDataStart()[offset]);
204  dest[0] = src[3];
205  dest[1] = src[2];
206  dest[2] = src[1];
207  dest[3] = src[0];
208 
209  ret = ((double)tmp) / 1048576.0;
210  return ret;
211 }
212 
213 // little endian
214 union Itypes {
216  struct
217  {
219  } i32;
220  struct
221  {
223  } i16;
224  struct
225  {
226  signed char b7, b6, b5, b4, b3, b2, b1, b0;
227  } i8;
228 
229  double d;
230  struct
231  {
232  float f1, f0;
233  } f32;
234 };
235 
236 //////////////////////////////////////////////////////////////////////////////////////////
237 // Return the current value of the data as a double(64 bits), after converting
238 // it from FP1632.
240 {
242 
243  int16_t fpint;
244  int32_t fpfrac;
245 
246  uint8_t* dest = (uint8_t*)&fpfrac;
247  uint8_t* src = &(getDataStart()[offset]);
248  dest[3] = *(src++);
249  dest[2] = *(src++);
250  dest[1] = *(src++);
251  dest[0] = *(src++);
252 
253  dest = (uint8_t*)&fpint;
254  dest[1] = *(src++);
255  dest[0] = *(src++);
256 
257  Itypes fp;
258  fp.i32.i0 = fpint;
259  fp.i32.i1 = fpfrac;
260 
261  return (double)fp.i64 / 4294967296.0;
262 }
263 
264 //////////////////////////////////////////////////////////////////////////////////////////
265 // Return current data value as a double(64 bits), after converting it from
266 // float, double, FP1632 or FP1220 depending on outputSettings
268  const uint64_t outputSettings, const uint16_t offset) const
269 {
270  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
271  {
273  return getDataFloat(offset);
274 
276  return getDataDouble(offset);
277 
279  return getDataFP1632(offset);
280 
282  return getDataF1220(offset);
283  }
284  return 0.0; // should never happen
285 }
286 
287 //////////////////////////////////////////////////////////////////////////////////////////
288 // Return current data values as a double(64 bits), after converting it from
289 // float, double, FP1632 or FP1220 depending on outputSettings
291  double* dest, const uint64_t outputSettings, uint16_t offset,
292  const int16_t numValues) const
293 {
294  for (uint16_t i = 0; i < numValues; i++)
295  {
296  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
297  {
299  *dest++ = getDataFloat(offset);
300  offset += 4;
301  break;
302 
304  *dest++ = getDataDouble(offset);
305  offset += 8;
306  break;
307 
309  *dest++ = getDataFP1632(offset);
310  offset += 6;
311  break;
312 
314  *dest++ = getDataF1220(offset);
315  offset += 4;
316  }
317  }
318 }
319 
320 //////////////////////////////////////////////////////////////////////////////////////////
321 // Return the current value of the data as an uint32_t (32 bits).
323 {
325  uint32_t ret;
326  uint8_t* dest = (uint8_t*)&ret;
327  uint8_t* src = &(getDataStart()[offset]);
328  dest[0] = src[3];
329  dest[1] = src[2];
330  dest[2] = src[1];
331  dest[3] = src[0];
332 
333  return ret;
334 }
335 
336 //////////////////////////////////////////////////////////////////////////////////////////
337 // Return the current value of the data as an uint16_t (16 bits).
339 {
341  uint16_t ret;
342  uint8_t* dest = (uint8_t*)&ret;
343  uint8_t* src = &(getDataStart()[offset]);
344  dest[0] = src[1];
345  dest[1] = src[0];
346 
347  return ret;
348 }
349 
350 //////////////////////////////////////////////////////////////////////////////////////////
351 // Return the length of the message buffer.
353 {
355  if (m_buffer->m_length == 255)
356  return (
359  else
360  return m_buffer->m_length;
361 }
362 
363 //////////////////////////////////////////////////////////////////////////////////////////
364 // Internal function to get the start of the data buffer.
366 {
368  if (m_buffer->m_length == 255)
369  {
370  return const_cast<uint8_t*>(m_buffer->m_datlen.m_extended.m_data);
371  }
372  else
373  return const_cast<uint8_t*>(m_buffer->m_datlen.m_data);
374 }
375 
376 //////////////////////////////////////////////////////////////////////////////////////////
377 // Return the length of the message buffer.
379 {
381  if (m_buffer->m_length == 255)
385  else
387 }
388 
389 //////////////////////////////////////////////////////////////////////////////////////////
390 bool Message::isChecksumOk(void) const
391 {
392  if (getTotalMessageSize() > m_maxLength) return false;
393  return calcChecksum() == m_checksum[0];
394 }
395 
396 //////////////////////////////////////////////////////////////////////////////////////////
397 // Read the entire message from the given source string
399  const uint8_t* source, const uint16_t size)
400 {
402  if (size > m_maxLength) return XRV_PARAMINVALID;
404  m_checksum = ((uint8_t*)m_buffer) + size - 1;
405  // check the size
407  {
411  return XRV_DATACORRUPT;
412  }
413  else
414  {
416  return XRV_DATACORRUPT;
417  }
418 
419  if (m_checksum[0] != calcChecksum()) return XRV_CHECKSUMFAULT;
420  return XRV_OK;
421 }
422 
423 //////////////////////////////////////////////////////////////////////////////////////////
424 void Message::resizeData(const uint16_t newSize)
425 {
427  int32_t index, oldLength;
428 
429  MSGLOG("Message.resizeData(%hu): buffer = %p\n", newSize, m_buffer);
430 
431  if ((uint32_t)(newSize + CMT_LEN_MSGEXTHEADERCS) > m_maxLength)
432  {
434  if ((newSize + CMT_LEN_MSGEXTHEADERCS) > newLen)
435  newLen = newSize + CMT_LEN_MSGEXTHEADERCS;
436  m_buffer = (MessageHeader*)realloc(m_buffer, newLen);
437  m_maxLength = newLen;
438  }
439 
440  MSGLOG(
441  "Message.resizeData after realloc(%hu): buffer = %p\n", m_maxLength,
442  m_buffer);
443 
444  if (newSize >= CMT_EXTLENCODE)
445  {
447  {
448  // make extended, shift all data 2 bytes up
449  for (index = (int32_t)m_buffer->m_length; index >= 0; --index)
452 
453  oldLength = m_buffer->m_length;
455  }
456  else
457  {
458  oldLength =
461  }
462  m_buffer->m_datlen.m_extended.m_length.m_high = (uint8_t)(newSize >> 8);
464 
465  for (index = oldLength; index < newSize; ++index)
467 
469  }
470  else
471  {
473  {
474  oldLength =
477  // un-extend, shift all data 2 bytes down
478  for (index = 0; index < newSize; ++index)
481  }
482  else
483  oldLength = m_buffer->m_length;
484  m_buffer->m_length = (uint8_t)newSize;
485  for (index = oldLength; index < newSize; ++index)
487  m_checksum = &m_buffer->m_datlen.m_data[newSize];
488  }
490  MSGLOG("Message.resizeData end(%hu): buffer = %p\n", m_maxLength, m_buffer);
492 }
493 
494 //////////////////////////////////////////////////////////////////////////////////////////
495 // Set the new value of the m_busId field and update the checksum.
496 void Message::setBusId(const uint8_t busId)
497 {
499  if (m_autoUpdateChecksum) m_checksum[0] += m_buffer->m_busId - busId;
500  m_buffer->m_busId = busId;
501 }
502 
503 //////////////////////////////////////////////////////////////////////////////////////////
504 // Write a string of bytes into the data buffer.
506  const uint8_t* data, const uint16_t offset, const uint16_t count)
507 {
510 
511  if (count > 0)
512  {
513  uint8_t* dest = &(getDataStart()[offset]);
514  for (uint16_t i = 0; i < count; ++i)
515  {
516  if (m_autoUpdateChecksum) m_checksum[0] += dest[i] - data[i];
517  dest[i] = data[i];
518  }
519  }
520 }
521 
522 //////////////////////////////////////////////////////////////////////////////////////////
524 {
526  if (getDataSize() < offset + 1) resizeData(offset + 1);
527 
528  uint8_t* dest = &(getDataStart()[offset]);
529  if (m_autoUpdateChecksum) m_checksum[0] += dest[0] - data;
530  dest[0] = data;
531 }
532 
533 //////////////////////////////////////////////////////////////////////////////////////////
534 void Message::setDataDouble(const double data, const uint16_t offset)
535 {
537  if (getDataSize() < offset + 8) resizeData(offset + 8);
538 
539  uint8_t* dest = &(getDataStart()[offset]);
540  const uint8_t* cdata = (const uint8_t*)&data;
542  m_checksum[0] += dest[0] + dest[1] + dest[2] + dest[3] + dest[4] +
543  dest[5] + dest[6] + dest[7] - cdata[0] - cdata[1] -
544  cdata[2] - cdata[3] - cdata[4] - cdata[5] - cdata[6] -
545  cdata[7];
546 
547  const uint8_t* src = (const uint8_t*)&data;
548  dest[0] = src[7];
549  dest[1] = src[6];
550  dest[2] = src[5];
551  dest[3] = src[4];
552  dest[4] = src[3];
553  dest[5] = src[2];
554  dest[6] = src[1];
555  dest[7] = src[0];
556 }
557 
558 //////////////////////////////////////////////////////////////////////////////////////////
559 void Message::setDataFloat(const float data, const uint16_t offset)
560 {
562  if (getDataSize() < offset + 4) resizeData(offset + 4);
563 
564  uint8_t* dest = &(getDataStart()[offset]);
565  const uint8_t* cdata = (const uint8_t*)&data;
567  m_checksum[0] += dest[0] + dest[1] + dest[2] + dest[3] - cdata[0] -
568  cdata[1] - cdata[2] - cdata[3];
569 
570  const uint8_t* src = (const uint8_t*)&data;
571  dest[0] = src[3];
572  dest[1] = src[2];
573  dest[2] = src[1];
574  dest[3] = src[0];
575 }
576 
577 //////////////////////////////////////////////////////////////////////////////////////////
578 void Message::setDataF1220(const double data, const uint16_t offset)
579 {
580  int32_t val = (int32_t)(data * 1048576.0);
582 }
583 
584 //////////////////////////////////////////////////////////////////////////////////////////
585 // Return the current value of the data as a double(64 bits), after converting
586 // it from F1220.
587 void Message::setDataFP1632(const double data, const uint16_t offset)
588 {
590 
591  if (getDataSize() < offset + 6) resizeData(offset + 6);
592 
593  Itypes fp;
594  fp.d = data;
595  int32_t dexp = ((fp.i32.i0 & (0x7fffffffL)) >> 20) - 1023;
596 
597  int16_t fpint;
598  int32_t fpfrac;
599 
600  if (dexp <= 14)
601  {
602  fp.i16.s0 = (fp.i16.s0 & 0x000F) | 0x0010;
603  if (data < 0) fp.i64 = -fp.i64;
604  if (dexp > -32)
605  fp.i64 = fp.i64 >> (20 - dexp); // 52-32 - exponent
606  else
607  fp.i64 = fp.i64 >> 52; // this could be optimized?
608  fpint = fp.i16.s1;
609  fpfrac = fp.i32.i1;
610  }
611  else
612  {
613  if (data < 0)
614  {
615  fpint = ((int16_t)(0x8000));
616  fpfrac = 0;
617  }
618  else
619  {
620  fpint = 0x7fff;
621  fpfrac = -1;
622  }
623  }
624 
625  uint8_t* src = (uint8_t*)&fpfrac;
626  uint8_t* dest = &(getDataStart()[offset]);
627 
628  *(dest++) = src[3];
629  *(dest++) = src[2];
630  *(dest++) = src[1];
631  *(dest++) = src[0];
632 
633  src = (uint8_t*)&fpint;
634  *(dest++) = src[1];
635  *(dest++) = src[0];
636 }
637 
638 //////////////////////////////////////////////////////////////////////////////////////////
640  const uint64_t outputSettings, const double data, const uint16_t offset)
641 {
642  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
643  {
645  return setDataFloat((const float)data, offset);
646 
648  return setDataDouble(data, offset);
649 
651  return setDataFP1632(data, offset);
652 
654  return setDataF1220(data, offset);
655  }
656 }
657 
658 //////////////////////////////////////////////////////////////////////////////////////////
660  const uint64_t outputSettings, const double* data, uint16_t offset,
661  const uint16_t numValues)
662 {
663  for (uint16_t i = 0; i < numValues; i++)
664  {
665  switch (outputSettings & CMT_OUTPUTSETTINGS_DATAFORMAT_MASK)
666  {
668  setDataFloat((float)data[i], offset);
669  offset += 4;
670  break;
671 
674  offset += 8;
675  break;
676 
679  offset += 6;
680  break;
681 
683  setDataF1220(data[i], offset);
684  offset += 4;
685  }
686  }
687 }
688 
689 //////////////////////////////////////////////////////////////////////////////////////////
691 {
693  if (getDataSize() < offset + 4) resizeData(offset + 4);
694 
695  uint8_t* dest = &(getDataStart()[offset]);
697  m_checksum[0] += (uint8_t)(
698  dest[0] + dest[1] + dest[2] + dest[3] - (data & 0xFF) -
699  ((data >> 8) & 0xFF) - ((data >> 16) & 0xFF) -
700  ((data >> 24) & 0xFF));
701 
702  const uint8_t* src = (const uint8_t*)&data;
703  dest[0] = src[3];
704  dest[1] = src[2];
705  dest[2] = src[1];
706  dest[3] = src[0];
707 }
708 
709 //////////////////////////////////////////////////////////////////////////////////////////
711 {
713  if (getDataSize() < offset + 2) resizeData(offset + 2);
714 
715  uint8_t* dest = &(getDataStart()[offset]);
717  m_checksum[0] += dest[0] + dest[1] - (data & 255) - (data >> 8);
718 
719  const uint8_t* src = (const uint8_t*)&data;
720  dest[0] = src[1];
721  dest[1] = src[0];
722 }
723 
724 //////////////////////////////////////////////////////////////////////////////////////////
725 // Set the new value of the m_messageId field and update the checksum.
727 {
730  m_buffer->m_messageId = msgId;
731 }
732 
733 //////////////////////////////////////////////////////////////////////////////////////////
734 // Copy message src into this
736 {
738 
739  if (m_maxLength != src.m_maxLength)
740  {
741  CHKDELNUL(m_buffer);
742  m_maxLength = src.m_maxLength;
743  m_buffer = (MessageHeader*)new char[m_maxLength];
744  }
745  memcpy(m_buffer, src.m_buffer, m_maxLength);
746  ptrdiff_t add = (uint8_t*)src.m_checksum - (uint8_t*)src.m_buffer;
747  m_checksum = (uint8_t*)m_buffer + add;
748 }
749 
750 //////////////////////////////////////////////////////////////////////////////////////////
751 // Remove a number of bytes from the message (this will reduce the message size)
753 {
754  if (size == 0) return;
755  uint16_t oldSize = getDataSize();
756  uint16_t newSize;
757  if (offset >= oldSize) return;
758 
759  if (oldSize > offset + size)
760  newSize = oldSize - size;
761  else
762  newSize = offset;
763 
764  // shift all bytes after the offset down by size positions
766  for (uint16_t i = offset; i < newSize; ++i) address[i] = address[i + size];
767 
768  // reduce the message length
769  resizeData(newSize);
770 }
771 
772 //////////////////////////////////////////////////////////////////////////////////////////
773 // Insert a number of bytes into the message (this will increase the message
774 // size)
776 {
777  if (size == 0) return;
778  // stretch the message
779  uint16_t oldSize = getDataSize();
780  resizeData(oldSize + size);
781  // shift the bytes after the offset up by size positions
783  for (uint16_t i = oldSize - 1; i >= offset && i < oldSize; --i)
784  address[i + size] = address[i];
785 }
786 
787 //////////////////////////////////////////////////////////////////////////////////////////
788 // Compute the checksum of the given byte string.
790 {
791  uint8_t cs = 0;
792  while (length--) cs -= *(buffer++);
793 
794  return cs;
795 }
796 
797 } // end of xsens namespace
#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:322
Operation was performed successfully.
Definition: xsens_std.h:34
#define CMT_CHECKASSERT
Definition: cmtmessage.h:73
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:267
A message header.
Definition: cmtmessage.h:36
GLuint GLuint GLsizei count
Definition: glext.h:3528
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:639
signed char b4
Definition: cmtmessage.cpp:226
signed char b1
Definition: cmtmessage.cpp:226
signed char b6
Definition: cmtmessage.cpp:226
#define CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632
Definition: cmtdef.h:638
unsigned __int16 uint16_t
Definition: rptypes.h:44
uint8_t * getDataStart(void) const
Internal function to get the start of the data buffer.
Definition: cmtmessage.cpp:365
#define CMT_CHECKASSIGN
Definition: cmtmessage.h:72
uint8_t m_data[CMT_MAXDATALEN]
Definition: cmtmessage.h:50
void resizeData(const uint16_t newSize)
Resize the data area to the given size.
Definition: cmtmessage.cpp:424
void operator=(const Message &src)
Copy message src into this.
Definition: cmtmessage.cpp:735
GLuint buffer
Definition: glext.h:3917
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:239
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:752
GLintptr offset
Definition: glext.h:3925
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:197
struct xsens::Itypes::@81 i16
#define CMT_MAXMSGLEN
Definition: cmtdef.h:77
void clear(void)
Clear all data in the message.
Definition: cmtmessage.cpp:147
uint16_t getDataSize(void) const
Return the length of the data part of the message.
Definition: cmtmessage.cpp:352
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:775
GLuint src
Definition: glext.h:7278
~Message()
Destructor.
Definition: cmtmessage.cpp:138
#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:338
signed char b7
Definition: cmtmessage.cpp:226
void recomputeChecksum(void)
Compute the checksum field and fill it.
Definition: cmtmessage.h:270
#define CMT_LEN_MSGEXTHEADER
Definition: cmtdef.h:66
unsigned char uint8_t
Definition: rptypes.h:41
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:89
struct xsens::Itypes::@82 i8
uint8_t computeChecksum(const uint8_t *buffer, uint32_t length)
Compute the checksum of the given byte string.
Definition: cmtmessage.cpp:789
__int16 int16_t
Definition: rptypes.h:43
float getDataFloat(const uint16_t offset=0) const
Return the current value of the data as a float (32 bits).
Definition: cmtmessage.cpp:180
__int64 int64_t
Definition: rptypes.h:49
GLuint index
Definition: glext.h:4054
XsensResultValue
Xsens return values.
Definition: xsens_std.h:31
int val
Definition: mrpt_jpeglib.h:955
#define CMT_LEN_MSGEXTHEADERCS
Definition: cmtdef.h:68
void setDataFloat(const float data, const uint16_t offset=0)
Write a float (32 bits) into the data buffer.
Definition: cmtmessage.cpp:559
signed char b5
Definition: cmtmessage.cpp:226
XsensResultValue loadFromString(const uint8_t *source, const uint16_t size)
Read the entire message from the given source string.
Definition: cmtmessage.cpp:398
#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:690
#define CMT_PREAMBLE
Definition: cmtdef.h:60
_W64 int ptrdiff_t
Definition: glew.h:137
#define CMT_EXTLENCODE
Definition: cmtdef.h:63
void setDataDouble(const double data, const uint16_t offset=0)
Write a double (64 bits) into the data buffer.
Definition: cmtmessage.cpp:534
uint8_t * getDataBuffer(const uint16_t offset=0)
Return a pointer to the data buffer.
Definition: cmtmessage.h:157
__int32 int32_t
Definition: rptypes.h:46
unsigned __int64 uint64_t
Definition: rptypes.h:50
signed char b0
Definition: cmtmessage.cpp:226
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:587
uint8_t calcChecksum(void) const
Internal checksum computation.
Definition: cmtmessage.h:96
#define CMT_LEN_MSGHEADERCS
Definition: cmtdef.h:67
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
signed char b3
Definition: cmtmessage.cpp:226
GLuint address
Definition: glext.h:6947
The namespace of all Xsens software since 2006.
Definition: cmt1.cpp:95
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:505
signed char b2
Definition: cmtmessage.cpp:226
GLsizei maxLength
Definition: glext.h:4932
#define CMT_LEN_MSGHEADER
Definition: cmtdef.h:65
void setMessageId(const uint8_t msgId)
Set the new value of the m_messageId field and update the checksum.
Definition: cmtmessage.cpp:726
void setBusId(const uint8_t busId)
Set the new value of the m_busId field and update the checksum.
Definition: cmtmessage.cpp:496
GLsizeiptr size
Definition: glext.h:3923
struct xsens::MessageHeader::_mdl::_mextd::_mlen m_length
bool m_autoUpdateChecksum
Definition: cmtmessage.h:105
uint16_t getTotalMessageSize(void) const
Return the length of the message buffer.
Definition: cmtmessage.cpp:378
unsigned __int32 uint32_t
Definition: rptypes.h:47
bool isChecksumOk(void) const
Compute the checksum and compare it with the stored checksum.
Definition: cmtmessage.cpp:390
uint8_t * m_checksum
The checksum in the m_data or m_extendedData buffer.
Definition: cmtmessage.h:91
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3546
#define CMT_BID_MASTER
Definition: cmtdef.h:61
double getDataDouble(const uint16_t offset=0) const
Return the current value of the data as a double (64 bits).
Definition: cmtmessage.cpp:160
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:578
void setDataByte(const uint8_t data, const uint16_t offset=0)
Write an unsigned byte (8 bits) into the data buffer.
Definition: cmtmessage.cpp:523
uint32_t m_maxLength
The maximum size of the message, including header and footer.
Definition: cmtmessage.h:93
Class for storing a single message.
Definition: cmtmessage.h:83
union xsens::MessageHeader::_mdl m_datlen
struct xsens::Itypes::@80 i32
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
Definition: os.cpp:356
void setDataShort(const uint16_t data, const uint16_t offset=0)
Write an uint16_t (16 bits) into the data buffer.
Definition: cmtmessage.cpp:710
struct xsens::Itypes::@83 f32



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020