xsens_imu
cmtdef.h
Go to the documentation of this file.
1 
30 #ifndef CMTDEF_H
31 #define CMTDEF_H
32 
33 #ifndef XSENS_MONOLITHIC
34 #ifndef _PSTDINT_H_INCLUDED
35 # include "pstdint.h"
36 #endif
37 #endif
38 #include <time.h>
39 
40 #ifdef _WIN32
41 #else
42 # include <termios.h>
43 # include <string.h>
44 # ifndef B460800
45 # undef B230400
46 # define B230400 0010003
47 # define B460800 0010004
48 # define B921600 0010007
49 # endif
50 // required for gnu c++ compiler due to difference in attribute declarations
51 # define __cdecl __attribute__((cdecl))
52 # define __stdcall __attribute__((stdcall))
53 #endif
54 
55 #ifndef XSENS_STD_H
56 # include "xsens_std.h"
57 #endif
58 #if !defined(XSENS_TIME_H) &&!defined(CMT_DLL_IMPORT)
59 # include "xsens_time.h"
60 #endif
61 
62 #ifndef XSENS_FILE_H
63 # include "xsens_file.h"
64 #endif
65 
66 #ifdef __cplusplus
67 #include <string.h>
68 #endif
69 
71 // Field message indices
72 #define CMT_IND_PREAMBLE 0
73 #define CMT_IND_BID 1
74 #define CMT_IND_MID 2
75 #define CMT_IND_LEN 3
76 #define CMT_IND_DATA0 4
77 #define CMT_IND_LENEXTH 4
78 #define CMT_IND_LENEXTL 5
79 #define CMT_IND_DATAEXT0 6
80 
81 #define CMT_PREAMBLE 0xFA
82 #define CMT_BID_MASTER 0xFF
83 #define CMT_BID_MT 0x01
84 #define CMT_EXTLENCODE 0xFF
85 
86 #define CMT_LEN_MSGHEADER 4
87 #define CMT_LEN_MSGEXTHEADER 6
88 #define CMT_LEN_MSGHEADERCS 5
89 #define CMT_LEN_MSGEXTHEADERCS 7
90 #define CMT_LEN_CHECKSUM 1
91 #define CMT_LEN_UNSIGSHORT 2
92 #define CMT_LEN_UNSIGINT 4
93 #define CMT_LEN_FLOAT 4
94 
95 // Maximum message/data length
96 #define CMT_MAXDATALEN 8192
97 #define CMT_MAXSHORTDATALEN 254
98 #define CMT_MAXMSGLEN (CMT_MAXDATALEN+7)
99 #define CMT_MAXSHORTMSGLEN (CMT_MAXSHORTDATALEN+5)
100 #define CMT_MAXGARBAGE (CMT_MAXMSGLEN+1)
101 
102 
103 // DID Type (high nibble)
104 #define CMT_DID_TYPEH_MASK 0x00F00000
105 #define CMT_DID_TYPEL_MASK 0x000F0000
106 #define CMT_DID_TYPEH_MT 0x00000000
107 #define CMT_DID_TYPEH_XM 0x00100000
108 #define CMT_DID_TYPEH_MTI_MTX 0x00300000
109 #define CMT_DID_TYPEH_MTIG 0x00500000
110 #define CMT_DID_TYPE_MASK 0x00FF0000
111 #define CMT_DID_TYPE_MASK_MT_232 0x00300000
112 #define CMT_DID_TYPE_MASK_MT_422 0x00310000
113 #define CMT_DID_TYPE_MASK_MT_XM 0x00020000
114 #define CMT_DID_TYPE_MASK_MT_485 0x00330000
115 
116 // All Message identifiers
117 // WakeUp state messages
118 #define CMT_MID_WAKEUP 0x3E
119 #define CMT_MID_WAKEUPACK 0x3F
120 
121 // Config state messages
122 #define CMT_MID_REQDID 0x00
123 #define CMT_MID_DEVICEID 0x01
124 #define CMT_LEN_DEVICEID 4
125 #define CMT_MID_INITBUS 0x02
126 #define CMT_MID_INITBUSRESULTS 0x03
127 #define CMT_LEN_INITBUSRESULTS 4
128 #define CMT_MID_REQPERIOD 0x04
129 #define CMT_MID_REQPERIODACK 0x05
130 #define CMT_LEN_PERIOD 2
131 #define CMT_MID_SETPERIOD 0x04
132 #define CMT_MID_SETPERIODACK 0x05
133 // XbusMaster
134 #define CMT_MID_SETBID 0x06
135 #define CMT_MID_SETBIDACK 0x07
136 #define CMT_MID_AUTOSTART 0x06
137 #define CMT_MID_AUTOSTARTACK 0x07
138 #define CMT_MID_BUSPWR 0x08
139 #define CMT_LEN_BUSPWR 2
140 #define CMT_MID_BUSPWRACK 0x09
141 // End XbusMaster
142 #define CMT_MID_REQDATALENGTH 0x0A
143 #define CMT_MID_DATALENGTH 0x0B
144 #define CMT_LEN_DATALENGTH 2
145 #define CMT_MID_REQCONFIGURATION 0x0C
146 #define CMT_MID_CONFIGURATION 0x0D
147 #define CMT_LEN_CONFIGURATION 118
148 #define CMT_MID_RESTOREFACTORYDEF 0x0E
149 #define CMT_MID_RESTOREFACTORYDEFACK 0x0F
150 
151 #define CMT_MID_GOTOMEASUREMENT 0x10
152 #define CMT_MID_GOTOMEASUREMENTACK 0x11
153 #define CMT_MID_REQFWREV 0x12
154 #define CMT_MID_FIRMWAREREV 0x13
155 #define CMT_LEN_FIRMWAREREV 3
156 // XbusMaster
157 #define CMT_MID_REQBTDISABLE 0x14
158 #define CMT_MID_REQBTDISABLEACK 0x15
159 #define CMT_LEN_BTDISABLE 1
160 #define CMT_MID_DISABLEBT 0x14
161 #define CMT_MID_DISABLEBTACK 0x15
162 #define CMT_MID_REQOPMODE 0x16
163 #define CMT_MID_REQOPMODEACK 0x17
164 #define CMT_LEN_OPMODE 1
165 #define CMT_MID_SETOPMODE 0x16
166 #define CMT_MID_SETOPMODEACK 0x17
167 // End XbusMaster
168 #define CMT_MID_REQBAUDRATE 0x18
169 #define CMT_MID_REQBAUDRATEACK 0x19
170 #define CMT_LEN_BAUDRATE 1
171 #define CMT_MID_SETBAUDRATE 0x18
172 #define CMT_MID_SETBAUDRATEACK 0x19
173 // XbusMaster
174 #define CMT_MID_REQSYNCMODE 0x1A
175 #define CMT_MID_REQSYNCMODEACK 0x1B
176 #define CMT_LEN_SYNCMODE 1
177 #define CMT_MID_SETSYNCMODE 0x1A
178 #define CMT_MID_SETSYNCMODEACK 0x1B
179 // End XbusMaster
180 #define CMT_MID_REQPRODUCTCODE 0x1C
181 #define CMT_MID_PRODUCTCODE 0x1D
182 #define CMT_LEN_PRODUCTCODE 20
183 
184 #define CMT_MID_REQPROCESSINGFLAGS 0x20
185 #define CMT_MID_REQPROCESSINGFLAGSACK 0x21
186 #define CMT_LEN_PROCESSINGFLAGS 2
187 #define CMT_MID_SETPROCESSINGFLAGS 0x20
188 #define CMT_MID_SETPROCESSINGFLAGSACK 0x21
189 
190 // XbusMaster
191 #define CMT_MID_XMPWROFF 0x44
192 #define CMT_LEN_XMPWROFF 0
193 // End XbusMaster
194 
195 #define CMT_MID_REQOUTPUTMODE 0xD0
196 #define CMT_MID_REQOUTPUTMODEACK 0xD1
197 #define CMT_LEN_OUTPUTMODE 2
198 #define CMT_MID_SETOUTPUTMODE 0xD0
199 #define CMT_MID_SETOUTPUTMODEACK 0xD1
200 
201 #define CMT_MID_REQOUTPUTSETTINGS 0xD2
202 #define CMT_MID_REQOUTPUTSETTINGSACK 0xD3
203 #define CMT_LEN_OUTPUTSETTINGS 4
204 #define CMT_MID_SETOUTPUTSETTINGS 0xD2
205 #define CMT_MID_SETOUTPUTSETTINGSACK 0xD3
206 
207 #define CMT_MID_REQOUTPUTSKIPFACTOR 0xD4
208 #define CMT_MID_REQOUTPUTSKIPFACTORACK 0xD5
209 #define CMT_LEN_OUTPUTSKIPFACTOR 2
210 #define CMT_MID_SETOUTPUTSKIPFACTOR 0xD4
211 #define CMT_MID_SETOUTPUTSKIPFACTORACK 0xD5
212 
213 #define CMT_MID_REQSYNCINSETTINGS 0xD6
214 #define CMT_MID_REQSYNCINSETTINGSACK 0xD7
215 #define CMT_LEN_SYNCINMODE 2
216 #define CMT_LEN_SYNCINSKIPFACTOR 2
217 #define CMT_LEN_SYNCINOFFSET 4
218 #define CMT_MID_SETSYNCINSETTINGS 0xD6
219 #define CMT_MID_SETSYNCINSETTINGSACK 0xD7
220 
221 #define CMT_MID_REQSYNCOUTSETTINGS 0xD8
222 #define CMT_MID_REQSYNCOUTSETTINGSACK 0xD9
223 #define CMT_LEN_SYNCOUTMODE 2
224 #define CMT_LEN_SYNCOUTSKIPFACTOR 2
225 #define CMT_LEN_SYNCOUTOFFSET 4
226 #define CMT_LEN_SYNCOUTPULSEWIDTH 4
227 #define CMT_MID_SETSYNCOUTSETTINGS 0xD8
228 #define CMT_MID_SETSYNCOUTSETTINGSACK 0xD9
229 
230 #define CMT_MID_REQERRORMODE 0xDA
231 #define CMT_MID_REQERRORMODEACK 0xDB
232 #define CMT_LEN_ERRORMODE 2
233 #define CMT_MID_SETERRORMODE 0xDA
234 #define CMT_MID_SETERRORMODEACK 0xDB
235 
236 #define CMT_MID_REQTRANSMITDELAY 0xDC
237 #define CMT_MID_REQTRANSMITDELAYACK 0xDD
238 #define CMT_LEN_TRANSMITDELAY 2
239 #define CMT_MID_SETTRANSMITDELAY 0xDC
240 #define CMT_MID_SETTRANSMITDELAYACK 0xDD
241 
242 #define CMT_MID_REQOBJECTALIGNMENT 0xE0
243 #define CMT_MID_REQOBJECTALIGNMENTACK 0xE1
244 #define CMT_LEN_OBJECTALIGNMENT 36
245 #define CMT_MID_SETOBJECTALIGNMENT 0xE0
246 #define CMT_MID_SETOBJECTALIGNMENTACK 0xE1
247 
248 // Xbus Master
249 #define CMT_MID_REQXMERRORMODE 0x82
250 #define CMT_MID_REQXMERRORMODEACK 0x83
251 #define CMT_LEN_XMERRORMODE 2
252 #define CMT_MID_SETXMERRORMODE 0x82
253 #define CMT_MID_SETXMERRORMODEACK 0x83
254 
255 #define CMT_MID_REQBUFFERSIZE 0x84
256 #define CMT_MID_REQBUFFERSIZEACK 0x85
257 #define CMT_LEN_BUFFERSIZE 2
258 #define CMT_MID_SETBUFFERSIZE 0x84
259 #define CMT_MID_SETBUFFERSIZEACK 0x85
260 // End Xbus Master
261 
262 #define CMT_MID_REQHEADING 0x82
263 #define CMT_MID_REQHEADINGACK 0x83
264 #define CMT_LEN_HEADING 4
265 #define CMT_MID_SETHEADING 0x82
266 #define CMT_MID_SETHEADINGACK 0x83
267 
268 #define CMT_MID_REQMAGNETICDECLINATION 0x6A
269 #define CMT_MID_REQMAGNETICDECLINATIONACK 0x6B
270 #define CMT_LEN_MAGNETICDECLINATION 4
271 #define CMT_MID_SETMAGNETICDECLINATION 0x6A
272 #define CMT_MID_SETMAGNETICDECLINATIONACK 0x6B
273 
274 #define CMT_MID_REQLOCATIONID 0x84
275 #define CMT_MID_REQLOCATIONIDACK 0x85
276 #define CMT_LEN_LOCATIONID 2
277 #define CMT_MID_SETLOCATIONID 0x84
278 #define CMT_MID_SETLOCATIONIDACK 0x85
279 
280 #define CMT_MID_REQEXTOUTPUTMODE 0x86
281 #define CMT_MID_REQEXTOUTPUTMODEACK 0x87
282 #define CMT_LEN_EXTOUTPUTMODE 2
283 #define CMT_MID_SETEXTOUTPUTMODE 0x86
284 #define CMT_MID_SETEXTOUTPUTMODEACK 0x87
285 
286 // XbusMaster
287 #define CMT_MID_REQBATLEVEL 0x88
288 #define CMT_MID_BATLEVEL 0x89
289 // End XbusMaster
290 
291 #define CMT_MID_REQINITTRACKMODE 0x88
292 #define CMT_MID_REQINITTRACKMODEACK 0x89
293 #define CMT_LEN_INITTRACKMODE 2
294 #define CMT_MID_SETINITTRACKMODE 0x88
295 #define CMT_MID_SETINITTRACKMODEACK 0x89
296 
297 #define CMT_MID_STOREXKFSTATE 0x8A
298 #define CMT_LEN_STOREXKFSTATE 0
299 #define CMT_MID_STOREXKFSTATEACK 0x8B
300 
301 #define CMT_MID_REQUTCTIME 0x60
302 #define CMT_MID_UTCTIME 0x61
303 #define CMT_LEN_UTCTIME 12
304 
305 #define CMT_LEN_SCENARIOLABEL 20
306 #define CMT_LEN_SCENARIOFULL (1+1+CMT_LEN_SCENARIOLABEL)
307 #define CMT_MID_REQAVAILABLESCENARIOS 0x62
308 #define CMT_MID_AVAILABLESCENARIOS 0x63
309 #define CMT_LEN_AVAILABLESCENARIOS (CMT_MAX_SCENARIOS_IN_MT*CMT_LEN_SCENARIOFULL)
310 
311 #define CMT_MID_REQSCENARIO 0x64
312 #define CMT_MID_REQSCENARIOACK 0x65
313 #define CMT_LEN_REQSCENARIOACK 2
314 #define CMT_MID_SETSCENARIO 0x64
315 #define CMT_MID_SETSCENARIOACK 0x65
316 #define CMT_LEN_SETSCENARIO 1
317 
318 #define CMT_MID_REQGRAVITYMAGNITUDE 0x66
319 #define CMT_MID_REQGRAVITYMAGNITUDEACK 0x67
320 #define CMT_MID_SETGRAVITYMAGNITUDE 0x66
321 #define CMT_MID_SETGRAVITYMAGNITUDEACK 0x67
322 #define CMT_LEN_GRAVITYMAGNITUDE 4
323 
324 #define CMT_MID_REQGPSLEVERARM 0x68
325 #define CMT_MID_REQGPSLEVERARMACK 0x69
326 #define CMT_MID_SETGPSLEVERARM 0x68
327 #define CMT_MID_SETGPSLEVERARMACK 0x69
328 #define CMT_LEN_GPSLEVERARM 12
329 
330 #define CMT_MID_REQLATLONALT 0x6E
331 #define CMT_MID_REQLATLONALTACK 0x6F
332 #define CMT_LEN_LATLONALT 18
333 #define CMT_MID_SETLATLONALT 0x6E
334 #define CMT_MID_SETLATLONALTACK 0x6F
335 
336 // Measurement state
337 #define CMT_MID_GOTOCONFIG 0x30
338 #define CMT_MID_GOTOCONFIGACK 0x31
339 #define CMT_MID_BUSDATA 0x32
340 #define CMT_MID_MTDATA 0x32
341 
342 #define CMT_MID_SETNOROTATION 0x22
343 #define CMT_MID_SETNOROTATIONACK 0x23
344 #define CMT_LEN_SETNOROTATION 2
345 
346 #define CMT_MID_RUNSELFTEST 0x24
347 #define CMT_MID_SELFTESTRESULTS 0x25
348 #define CMT_SELFTEST_OK 0x1FF
349 
350 // Manual
351 #define CMT_MID_PREPAREDATA 0x32
352 #define CMT_MID_REQDATA 0x34
353 #define CMT_MID_REQDATAACK 0x35
354 
355 // MTData defines
356 // Length of data blocks in bytes
357 #define CMT_LEN_RAWDATA 20
358 #define CMT_LEN_CALIBDATA 36
359 #define CMT_LEN_CALIB_ACCDATA 12
360 #define CMT_LEN_CALIB_GYRDATA 12
361 #define CMT_LEN_CALIB_MAGDATA 12
362 #define CMT_LEN_ORIENT_QUATDATA 16
363 #define CMT_LEN_ORIENT_EULERDATA 12
364 #define CMT_LEN_ORIENT_MATRIXDATA 36
365 #define CMT_LEN_SAMPLECNT 2
366 #define CMT_LEN_TEMPDATA 4
367 
368 // Length of data blocks in floats
369 #define CMT_LEN_CALIBDATA_FLT 9
370 #define CMT_LEN_TEMPDATA_FLT 1
371 #define CMT_LEN_ORIENT_QUATDATA_FLT 4
372 #define CMT_LEN_ORIENT_EULERDATA_FLT 3
373 #define CMT_LEN_ORIENT_MATRIXDATA_FLT 9
374 
375 // Indices of fields in DATA field of MTData message in bytes
376 // use in combination with LEN_CALIB etc
377 // Un-calibrated raw data
378 #define CMT_IND_RAW_ACCX 0
379 #define CMT_IND_RAW_ACCY 2
380 #define CMT_IND_RAW_ACCZ 4
381 #define CMT_IND_RAW_GYRX 6
382 #define CMT_IND_RAW_GYRY 8
383 #define CMT_IND_RAW_GYRZ 10
384 #define CMT_IND_RAW_MAGX 12
385 #define CMT_IND_RAW_MAGY 14
386 #define CMT_IND_RAW_MAGZ 16
387 #define CMT_IND_RAW_TEMP 18
388 // Calibrated data
389 #define CMT_IND_CALIB_ACCX 0
390 #define CMT_IND_CALIB_ACCY 4
391 #define CMT_IND_CALIB_ACCZ 8
392 #define CMT_IND_CALIB_GYRX 12
393 #define CMT_IND_CALIB_GYRY 16
394 #define CMT_IND_CALIB_GYRZ 20
395 #define CMT_IND_CALIB_MAGX 24
396 #define CMT_IND_CALIB_MAGY 28
397 #define CMT_IND_CALIB_MAGZ 32
398 // Orientation data - quat
399 #define CMT_IND_ORIENT_Q0 0
400 #define CMT_IND_ORIENT_Q1 4
401 #define CMT_IND_ORIENT_Q2 8
402 #define CMT_IND_ORIENT_Q3 12
403 // Orientation data - euler
404 #define CMT_IND_ORIENT_ROLL 0
405 #define CMT_IND_ORIENT_PITCH 4
406 #define CMT_IND_ORIENT_YAW 8
407 // Orientation data - matrix
408 #define CMT_IND_ORIENT_A 0
409 #define CMT_IND_ORIENT_B 4
410 #define CMT_IND_ORIENT_C 8
411 #define CMT_IND_ORIENT_D 12
412 #define CMT_IND_ORIENT_E 16
413 #define CMT_IND_ORIENT_F 20
414 #define CMT_IND_ORIENT_G 24
415 #define CMT_IND_ORIENT_H 28
416 #define CMT_IND_ORIENT_I 32
417 // Orientation data - euler
418 #define CMT_IND_SAMPLECNTH 0
419 #define CMT_IND_SAMPLECNTL 1
420 
421 // Indices of fields in DATA field of MTData message
422 // Un-calibrated raw data
423 #define CMT_FLDNUM_RAW_ACCX 0
424 #define CMT_FLDNUM_RAW_ACCY 1
425 #define CMT_FLDNUM_RAW_ACCZ 2
426 #define CMT_FLDNUM_RAW_GYRX 3
427 #define CMT_FLDNUM_RAW_GYRY 4
428 #define CMT_FLDNUM_RAW_GYRZ 5
429 #define CMT_FLDNUM_RAW_MAGX 6
430 #define CMT_FLDNUM_RAW_MAGY 7
431 #define CMT_FLDNUM_RAW_MAGZ 8
432 #define CMT_FLDNUM_RAW_TEMP 9
433 // Calibrated data
434 #define CMT_FLDNUM_CALIB_ACCX 0
435 #define CMT_FLDNUM_CALIB_ACCY 1
436 #define CMT_FLDNUM_CALIB_ACCZ 2
437 #define CMT_FLDNUM_CALIB_GYRX 3
438 #define CMT_FLDNUM_CALIB_GYRY 4
439 #define CMT_FLDNUM_CALIB_GYRZ 5
440 #define CMT_FLDNUM_CALIB_MAGX 6
441 #define CMT_FLDNUM_CALIB_MAGY 7
442 #define CMT_FLDNUM_CALIB_MAGZ 8
443 // Orientation data - quat
444 #define CMT_FLDNUM_ORIENT_Q0 0
445 #define CMT_FLDNUM_ORIENT_Q1 1
446 #define CMT_FLDNUM_ORIENT_Q2 2
447 #define CMT_FLDNUM_ORIENT_Q3 3
448 // Orientation data - euler
449 #define CMT_FLDNUM_ORIENT_ROLL 0
450 #define CMT_FLDNUM_ORIENT_PITCH 1
451 #define CMT_FLDNUM_ORIENT_YAW 2
452 // Orientation data - matrix
453 #define CMT_FLDNUM_ORIENT_A 0
454 #define CMT_FLDNUM_ORIENT_B 1
455 #define CMT_FLDNUM_ORIENT_C 2
456 #define CMT_FLDNUM_ORIENT_D 3
457 #define CMT_FLDNUM_ORIENT_E 4
458 #define CMT_FLDNUM_ORIENT_F 5
459 #define CMT_FLDNUM_ORIENT_G 6
460 #define CMT_FLDNUM_ORIENT_H 7
461 #define CMT_FLDNUM_ORIENT_I 8
462 // Length
463 // Uncalibrated raw data
464 #define CMT_LEN_RAW_ACCX 2
465 #define CMT_LEN_RAW_ACCY 2
466 #define CMT_LEN_RAW_ACCZ 2
467 #define CMT_LEN_RAW_GYRX 2
468 #define CMT_LEN_RAW_GYRY 2
469 #define CMT_LEN_RAW_GYRZ 2
470 #define CMT_LEN_RAW_MAGX 2
471 #define CMT_LEN_RAW_MAGY 2
472 #define CMT_LEN_RAW_MAGZ 2
473 #define CMT_LEN_RAW_TEMP 2
474 // Calibrated data
475 #define CMT_LEN_CALIB_ACCX 4
476 #define CMT_LEN_CALIB_ACCY 4
477 #define CMT_LEN_CALIB_ACCZ 4
478 #define CMT_LEN_CALIB_GYRX 4
479 #define CMT_LEN_CALIB_GYRY 4
480 #define CMT_LEN_CALIB_GYRZ 4
481 #define CMT_LEN_CALIB_MAGX 4
482 #define CMT_LEN_CALIB_MAGY 4
483 #define CMT_LEN_CALIB_MAGZ 4
484 // Orientation data - quat
485 #define CMT_LEN_ORIENT_Q0 4
486 #define CMT_LEN_ORIENT_Q1 4
487 #define CMT_LEN_ORIENT_Q2 4
488 #define CMT_LEN_ORIENT_Q3 4
489 // Orientation data - euler
490 #define CMT_LEN_ORIENT_ROLL 4
491 #define CMT_LEN_ORIENT_PITCH 4
492 #define CMT_LEN_ORIENT_YAW 4
493 // Orientation data - matrix
494 #define CMT_LEN_ORIENT_A 4
495 #define CMT_LEN_ORIENT_B 4
496 #define CMT_LEN_ORIENT_C 4
497 #define CMT_LEN_ORIENT_D 4
498 #define CMT_LEN_ORIENT_E 4
499 #define CMT_LEN_ORIENT_F 4
500 #define CMT_LEN_ORIENT_G 4
501 #define CMT_LEN_ORIENT_H 4
502 #define CMT_LEN_ORIENT_I 4
503 
504 // Defines for getDataValue
505 #define CMT_VALUE_RAW_ACC 0
506 #define CMT_VALUE_RAW_GYR 1
507 #define CMT_VALUE_RAW_MAG 2
508 #define CMT_VALUE_RAW_TEMP 3
509 #define CMT_VALUE_CALIB_ACC 4
510 #define CMT_VALUE_CALIB_GYR 5
511 #define CMT_VALUE_CALIB_MAG 6
512 #define CMT_VALUE_ORIENT_QUAT 7
513 #define CMT_VALUE_ORIENT_EULER 8
514 #define CMT_VALUE_ORIENT_MATRIX 9
515 #define CMT_VALUE_SAMPLECNT 10
516 #define CMT_VALUE_TEMP 11
517 
518 #define CMT_INVALIDSETTINGVALUE 0xFFFFFFFF
519 
520 // Valid in all states
521 #define CMT_MID_RESET 0x40
522 #define CMT_MID_RESETACK 0x41
523 #define CMT_MID_ERROR 0x42
524 // XbusMaster
525 #define CMT_MID_XMPWROFF 0x44
526 // End XbusMaster
527 
528 #define CMT_MID_REQFILTERSETTINGS 0xA0
529 #define CMT_MID_REQFILTERSETTINGSACK 0xA1
530 #define CMT_LEN_FILTERSETTINGS 4
531 #define CMT_MID_SETFILTERSETTINGS 0xA0
532 #define CMT_MID_SETFILTERSETTINGSACK 0xA1
533 #define CMT_MID_REQAMD 0xA2
534 #define CMT_MID_REQAMDACK 0xA3
535 #define CMT_LEN_AMD 2
536 #define CMT_MID_SETAMD 0xA2
537 #define CMT_MID_SETAMDACK 0xA3
538 #define CMT_MID_RESETORIENTATION 0xA4
539 #define CMT_MID_RESETORIENTATIONACK 0xA5
540 #define CMT_LEN_RESETORIENTATION 2
541 
542 #define CMT_MID_REQGPSSTATUS 0xA6
543 #define CMT_MID_GPSSTATUS 0xA7
544 #define CMT_LEN_GPSSTATUS (1+5*16)
545 
546 // Baudrate defines for SetBaudrate message
547 #define CMT_BAUDCODE_4K8 0x0B
548 #define CMT_BAUDCODE_9K6 0x09
549 // #define CMT_BAUDCODE_14K4 0x08
550 #define CMT_BAUDCODE_19K2 0x07
551 // #define CMT_BAUDCODE_28K8 0x06
552 #define CMT_BAUDCODE_38K4 0x05
553 #define CMT_BAUDCODE_57K6 0x04
554 // #define CMT_BAUDCODE_76K8 0x03
555 #define CMT_BAUDCODE_115K2 0x02
556 #define CMT_BAUDCODE_230K4 0x01
557 #define CMT_BAUDCODE_460K8 0x00
558 #define CMT_BAUDCODE_921K6_ALT 0x0A // only usable from FW 2.4.6
559 #define CMT_BAUDCODE_921K6 0x80
560 
561 // Xbus protocol error codes (Error)
562 #define CMT_ERROR_NOBUSCOMM 0x01
563 #define CMT_ERROR_BUSNOTREADY 0x02
564 #define CMT_ERROR_PERIODINVALID 0x03
565 #define CMT_ERROR_MESSAGEINVALID 0x04
566 #define CMT_ERROR_INITOFBUSFAILED1 0x10
567 #define CMT_ERROR_INITOFBUSFAILED2 0x11
568 #define CMT_ERROR_INITOFBUSFAILED3 0x12
569 #define CMT_ERROR_SETBIDPROCFAILED1 0x14
570 #define CMT_ERROR_SETBIDPROCFAILED2 0x15
571 #define CMT_ERROR_MEASUREMENTFAILED1 0x18
572 #define CMT_ERROR_MEASUREMENTFAILED2 0x19
573 #define CMT_ERROR_MEASUREMENTFAILED3 0x1A
574 #define CMT_ERROR_MEASUREMENTFAILED4 0x1B
575 #define CMT_ERROR_MEASUREMENTFAILED5 0x1C
576 #define CMT_ERROR_MEASUREMENTFAILED6 0x1D
577 #define CMT_ERROR_TIMEROVERFLOW 0x1E
578 #define CMT_ERROR_BAUDRATEINVALID 0x20
579 #define CMT_ERROR_PARAMETERINVALID 0x21
580 #define CMT_ERROR_MEASUREMENTFAILED7 0x23
581 
582 // Error modes (SetErrorMode)
583 #define CMT_ERRORMODE_IGNORE 0x0000
584 #define CMT_ERRORMODE_INCSAMPLECNT 0x0001
585 #define CMT_ERRORMODE_INCSAMPLECNT_SENDERROR 0x0002
586 #define CMT_ERRORMODE_SENDERROR_GOTOCONFIG 0x0003
587 
588 // Configuration message defines
589 #define CMT_CONF_MASTERDID 0
590 #define CMT_CONF_PERIOD 4
591 #define CMT_CONF_OUTPUTSKIPFACTOR 6
592 #define CMT_CONF_SYNCIN_MODE 8
593 #define CMT_CONF_SYNCIN_SKIPFACTOR 10
594 #define CMT_CONF_SYNCIN_OFFSET 12
595 #define CMT_CONF_DATE 16
596 #define CMT_CONF_TIME 24
597 #define CMT_CONF_NUMDEVICES 96
598 // Configuration sensor block properties
599 #define CMT_CONF_DID 98
600 #define CMT_CONF_DATALENGTH 102
601 #define CMT_CONF_OUTPUTMODE 104
602 #define CMT_CONF_OUTPUTSETTINGS 106
603 #define CMT_CONF_BLOCKLEN 20
604 // To calculate the offset in data field for output mode of sensor #2 use
605 // CONF_OUTPUTMODE + 1*CONF_BLOCKLEN
606 #define CMT_CONF_MASTERDIDLEN 4
607 #define CMT_CONF_PERIODLEN 2
608 #define CMT_CONF_OUTPUTSKIPFACTORLEN 2
609 #define CMT_CONF_SYNCIN_MODELEN 2
610 #define CMT_CONF_SYNCIN_SKIPFACTORLEN 2
611 #define CMT_CONF_SYNCIN_OFFSETLEN 4
612 #define CMT_CONF_DATELEN 8
613 #define CMT_CONF_TIMELEN 8
614 #define CMT_CONF_RESERVED_CLIENTLEN 32
615 #define CMT_CONF_RESERVED_HOSTLEN 32
616 #define CMT_CONF_NUMDEVICESLEN 2
617 // Configuration sensor block properties
618 #define CMT_CONF_DIDLEN 4
619 #define CMT_CONF_DATALENGTHLEN 2
620 #define CMT_CONF_OUTPUTMODELEN 2
621 #define CMT_CONF_OUTPUTSETTINGSLEN 4
622 
623 // Clock frequency for offset & pulse width
624 #define CMT_SYNC_CLOCKFREQMHZ 29.4912
625 #define CMT_SYNC_CLOCK_NS_TO_TICKS (CMT_SYNC_CLOCKFREQMHZ * 1.0e-3)
626 #define CMT_SYNC_CLOCK_TICKS_TO_NS (1.0e3 / CMT_SYNC_CLOCKFREQMHZ)
627 
628 // SyncIn params
629 #define CMT_PARAM_SYNCIN_MODE 0x00
630 #define CMT_PARAM_SYNCIN_SKIPFACTOR 0x01
631 #define CMT_PARAM_SYNCIN_OFFSET 0x02
632 
633 // SyncIn mode
634 #define CMT_SYNCIN_DISABLED 0x0000
635 #define CMT_SYNCIN_EDGE_RISING 0x0001
636 #define CMT_SYNCIN_EDGE_FALLING 0x0002
637 #define CMT_SYNCIN_EDGE_BOTH 0x0003
638 #define CMT_SYNCIN_EDGE_MASK 0x0003
639 #define CMT_SYNCIN_TYPE_DOSAMPLING 0x0000
640 #define CMT_SYNCIN_TYPE_SENDLASTDATA 0x0004
641 #define CMT_SYNCIN_TYPE_CLOCK 0x0010
642 #define CMT_SYNCIN_TYPE_MASK 0x001C
643 
644 // SyncOut params
645 #define CMT_PARAM_SYNCOUT_MODE 0x00
646 #define CMT_PARAM_SYNCOUT_SKIPFACTOR 0x01
647 #define CMT_PARAM_SYNCOUT_OFFSET 0x02
648 #define CMT_PARAM_SYNCOUT_PULSEWIDTH 0x03
649 
650 // SyncOut mode
651 #define CMT_SYNCOUT_DISABLED 0x0000
652 #define CMT_SYNCOUT_TYPE_TOGGLE 0x0001
653 #define CMT_SYNCOUT_TYPE_PULSE 0x0002
654 #define CMT_SYNCOUT_POL_NEG 0x0000
655 #define CMT_SYNCOUT_POL_POS 0x0010
656 #define CMT_SYNCOUT_TYPE_MASK 0x000F
657 #define CMT_SYNCOUT_POL_MASK 0x0010
658 
659 // OutputModes
660 #define CMT_OUTPUTMODE_MT9 0x8000
661 #define CMT_OUTPUTMODE_XM 0x0000
662 #define CMT_OUTPUTMODE_RAW 0x4000
663 //#define CMT_OUTPUTMODE_RAWGPSPRINT 0x1000 // Obsolete. Use CMT_OUTPUTMODE_GPSPVT_PRESSURE instead
664 #define CMT_OUTPUTMODE_GPSPVT_PRESSURE 0x1000
665 #define CMT_OUTPUTMODE_TEMP 0x0001
666 #define CMT_OUTPUTMODE_CALIB 0x0002
667 #define CMT_OUTPUTMODE_ORIENT 0x0004
668 #define CMT_OUTPUTMODE_AUXILIARY 0x0008
669 #define CMT_OUTPUTMODE_POSITION 0x0010
670 #define CMT_OUTPUTMODE_VELOCITY 0x0020
671 #define CMT_OUTPUTMODE_STATUS 0x0800
672 
673 // CmtOutputSettings
674 #define CMT_OUTPUTSETTINGS_XM 0x00000001
675 #define CMT_OUTPUTSETTINGS_TIMESTAMP_NONE 0x00000000
676 #define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT 0x00000001
677 #define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLEUTC 0x00000002
678 #define CMT_OUTPUTSETTINGS_ORIENTMODE_QUATERNION 0x00000000
679 #define CMT_OUTPUTSETTINGS_ORIENTMODE_EULER 0x00000004
680 #define CMT_OUTPUTSETTINGS_ORIENTMODE_MATRIX 0x00000008
681 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYRMAG 0x00000000
682 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACC 0x00000060
683 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYR 0x00000040
684 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCMAG 0x00000020
685 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYR 0x00000050
686 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYRMAG 0x00000010
687 #define CMT_OUTPUTSETTINGS_CALIBMODE_MAG 0x00000030
688 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYRMAG_MASK 0x00000070
689 #define CMT_OUTPUTSETTINGS_DATAFORMAT_FLOAT 0x00000000
690 #define CMT_OUTPUTSETTINGS_DATAFORMAT_F1220 0x00000100
691 #define CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632 0x00000200
692 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN1 0x00000800
693 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN2 0x00000400
694 #define CMT_OUTPUTSETTINGS_POSITIONMODE_LLA_WGS84 0x00000000
695 #define CMT_OUTPUTSETTINGS_VELOCITYMODE_MS_XYZ 0x00000000
696 #define CMT_OUTPUTSETTINGS_TIMESTAMP_MASK 0x00000003
697 #define CMT_OUTPUTSETTINGS_ORIENTMODE_MASK 0x0000000C
698 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACC_MASK 0x00000010
699 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYR_MASK 0x00000020
700 #define CMT_OUTPUTSETTINGS_CALIBMODE_MAG_MASK 0x00000040
701 #define CMT_OUTPUTSETTINGS_CALIBMODE_MASK 0x00000070
702 #define CMT_OUTPUTSETTINGS_DATAFORMAT_MASK 0x00000300
703 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN1_MASK 0x00000400
704 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN2_MASK 0x00000800
705 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_MASK 0x00000C00
706 #define CMT_OUTPUTSETTINGS_POSITIONMODE_MASK 0x0001C000
707 #define CMT_OUTPUTSETTINGS_VELOCITYMODE_MASK 0x00060000
708 #define CMT_OUTPUTSETTINGS_COORDINATES_NED 0x80000000
709 
710 // Extended (analog) Output Modes
711 #define CMT_EXTOUTPUTMODE_DISABLED 0x0000
712 #define CMT_EXTOUTPUTMODE_EULER 0x0001
713 
714 // Processing flags
715 #define CMT_PROCESSINGFLAGS_IGBU_ENABLED 0x0001
716 #define CMT_PROCESSINGFLAGS_FIXED_GRAVITY 0x0002
717 
718 // Send raw string mode
719 #define CMT_SENDRAWSTRING_INIT 0
720 #define CMT_SENDRAWSTRING_DEFAULT 1
721 #define CMT_SENDRAWSTRING_SEND 2
722 
723 // Timeouts
724 #define CMT_TO_DEFAULT 500
725 #define CMT_TO_INIT 250
726 #define CMT_TO_RETRY 50
727 
728 #define CMT_PERIOD_10HZ 11520 // invalid with gps pulse time correction
729 #define CMT_PERIOD_12HZ 9600
730 #define CMT_PERIOD_15HZ 7680 // invalid with gps pulse time correction
731 #define CMT_PERIOD_16HZ 7200
732 #define CMT_PERIOD_18HZ 6400 // invalid with gps pulse time correction
733 #define CMT_PERIOD_20HZ 5760
734 #define CMT_PERIOD_24HZ 4800
735 #define CMT_PERIOD_25HZ 4608 // invalid with gps pulse time correction
736 #define CMT_PERIOD_30HZ 3840
737 #define CMT_PERIOD_32HZ 3600
738 #define CMT_PERIOD_36HZ 3200
739 #define CMT_PERIOD_40HZ 2880
740 #define CMT_PERIOD_45HZ 2560 // invalid with gps pulse time correction
741 #define CMT_PERIOD_48HZ 2400
742 #define CMT_PERIOD_50HZ 2304 // invalid with gps pulse time correction
743 #define CMT_PERIOD_60HZ 1920
744 #define CMT_PERIOD_64HZ 1800
745 #define CMT_PERIOD_72HZ 1600
746 #define CMT_PERIOD_75HZ 1536 // invalid with gps pulse time correction
747 #define CMT_PERIOD_80HZ 1440
748 #define CMT_PERIOD_90HZ 1280 // invalid with gps pulse time correction
749 #define CMT_PERIOD_96HZ 1200
750 
751 #define CMT_PERIOD_100HZ 1152
752 #define CMT_PERIOD_120HZ 960
753 #define CMT_PERIOD_128HZ 900
754 #define CMT_PERIOD_144HZ 800
755 #define CMT_PERIOD_150HZ 768 // invalid with gps pulse time correction
756 #define CMT_PERIOD_160HZ 720
757 #define CMT_PERIOD_180HZ 640
758 #define CMT_PERIOD_192HZ 600
759 #define CMT_PERIOD_200HZ 576
760 #define CMT_PERIOD_225HZ 512 // invalid with gps pulse time correction
761 #define CMT_PERIOD_240HZ 480
762 #define CMT_PERIOD_256HZ 450
763 #define CMT_PERIOD_288HZ 400
764 #define CMT_PERIOD_300HZ 384
765 #define CMT_PERIOD_320HZ 360
766 #define CMT_PERIOD_360HZ 320
767 #define CMT_PERIOD_384HZ 300
768 #define CMT_PERIOD_400HZ 288
769 #define CMT_PERIOD_450HZ 256 // invalid with gps pulse time correction
770 #define CMT_PERIOD_480HZ 240
771 #define CMT_PERIOD_512HZ 225
772 
773 // openPort baudrates
774 #ifdef _WIN32
775  #define CMT_BAUD_RATE_4800 CBR_4800
776  #define CMT_BAUD_RATE_9600 CBR_9600
777 // #define CMT_BAUD_RATE_14K4 CBR_14400
778  #define CMT_BAUD_RATE_19K2 CBR_19200
779 // #define CMT_BAUD_RATE_28K8 28800
780  #define CMT_BAUD_RATE_38K4 CBR_38400
781  #define CMT_BAUD_RATE_57K6 CBR_57600
782  #define CMT_BAUD_RATE_115K2 CBR_115200
783  #define CMT_BAUD_RATE_230K4 230400
784  #define CMT_BAUD_RATE_460K8 460800
785  #define CMT_BAUD_RATE_921K6 921600
786 #else
787  #define CMT_BAUD_RATE_4800 B4800
788  #define CMT_BAUD_RATE_9600 B9600
789 // #define CMT_BAUD_RATE_14K4 B14400
790  #define CMT_BAUD_RATE_19K2 B19200
791 // #define CMT_BAUD_RATE_28K8 B28800
792  #define CMT_BAUD_RATE_38K4 B38400
793  #define CMT_BAUD_RATE_57K6 B57600
794  #define CMT_BAUD_RATE_115K2 B115200
795  #define CMT_BAUD_RATE_230K4 B230400
796  #define CMT_BAUD_RATE_460K8 B460800
797  #define CMT_BAUD_RATE_921K6 B921600
798 #endif
799 
800 #define CMT_DEFAULT_OUTPUT_MODE CMT_OUTPUTMODE_ORIENT
801 #define CMT_DEFAULT_OUTPUT_SETTINGS (CMT_OUTPUTSETTINGS_ORIENTMODE_QUATERNION |\
802  CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT)
803 
804 #define CMT_GOTO_CONFIG_TRIES 3
805 
806 #define CMT_MAX_DEVICES_PER_PORT 11
807 #define CMT_DEFAULT_SAMPLE_FREQUENCY 100
808 #define CMT_DEFAULT_PERIOD 1152
809 #define CMT_DEFAULT_SKIP 0
810 #define CMT_SYNCOUT_DEFAULT_PULSE_WIDTH 1000000 // 1ms = 1M ns
811 
812 #define CMT_MAX_PORTS_PER_THREAD 20
813 #define CMT_MAX_FILES_PER_THREAD 20
814 #if CMT_MAX_PORTS_PER_THREAD >= CMT_MAX_FILES_PER_THREAD
815 # define CMT_MAX_DEVICES (CMT_MAX_PORTS_PER_THREAD * CMT_MAX_DEVICES_PER_PORT)
816 #else
817 # define CMT_MAX_DEVICES (CMT_MAX_FILES_PER_THREAD * CMT_MAX_DEVICES_PER_PORT)
818 #endif
819 #define CMT_MAX_PACKETS_PER_BUNDLE CMT_MAX_PORTS_PER_THREAD
820 #define CMT_BUNDLE_QUEUE_SIZE 256
821 #define CMT_MAX_ITEMS_IN_PACKET 10
822 
824 #define CMT_DEFAULT_READ_BUFFER_SIZE (CMT_MAXDATALEN*8)
825 #define CMT_DEFAULT_WRITE_BUFFER_SIZE CMT_MAXDATALEN
827 #define CMT_DEFAULT_BAUD_RATE CMT_BAUD_RATE_115K2
829 #define CMT2_DATA_QUEUE_SIZE 60
831 
833 #define CMT3_CONFIG_TIMEOUT 100
834 #define CMT1_DEFAULT_TIMEOUT 10
836 #define CMT2_DEFAULT_TIMEOUT 50
838 #define CMT3_DEFAULT_TIMEOUT_MEAS 16
840 #define CMT3_DEFAULT_TIMEOUT_CONF 3000
842 #define CMT4_DEFAULT_TIMEOUT_MEAS 1
844 #define CMT4_DEFAULT_TIMEOUT_CONF CMT3_DEFAULT_TIMEOUT_CONF
846 #define CMT4_MEASUREMENT_REQ_TIMEOUT 200
848 #define CMT4_DEFAULT_TIMEOUT_DATA 3000
850 #define CMT4_CONFIGWAIT_TIMEOUT 50
852 
854  CMT_CONTROL_DCD = 0x0001, // pin 1: Carrier Detect
855  CMT_CONTROL_RD = 0x0002, // pin 2: Received Data
856  CMT_CONTROL_TD = 0x0004, // pin 3: Transmitted Data
857  CMT_CONTROL_DTR = 0x0008, // pin 4: Data Terminal Ready
858  CMT_CONTROL_GND = 0x0010, // pin 5: Common Ground
859  CMT_CONTROL_DSR = 0x0020, // pin 6: Data Set Ready
860  CMT_CONTROL_RTS = 0x0040, // pin 7: Request To Send
861  CMT_CONTROL_CTS = 0x0080, // pin 8: Clear To Send
862  CMT_CONTROL_RI = 0x0100 // pin 9: Ring Indicator
863 };
864 
865 // Reset orientation message type
872 };
873 
880 };
881 
883 typedef uint32_t CmtDeviceId;
884 
886 struct CmtVersion {
887  uint8_t m_major;
888  uint8_t m_minor;
889  uint8_t m_revision;
890 };
891 
892 /* different alignment commands for gcc / MSVS, the structure needs to be 2-byte aligned
893  because the deviceId field is 4 bytes long on offset 98.
894 */
895 #ifdef _MSC_VER
896  #pragma pack(push, 2)
897 #endif
898 struct CmtDeviceConfiguration {
903  uint16_t m_syncinMode;
905  uint32_t m_syncinOffset;
906  uint8_t m_date[8];
907  uint8_t m_time[8];
908  uint8_t m_reservedForHost[32];
909  uint8_t m_reservedForClient[32];
911  struct _devInfo {
912  uint32_t m_deviceId;
913  uint16_t m_dataLength;
914  uint16_t m_outputMode;
917  uint8_t m_fwRevMajor;
918  uint8_t m_fwRevMinor;
920  uint8_t m_filterType;
921  uint8_t m_filterMajor;
922  uint8_t m_filterMinor;
923  } m_deviceInfo[CMT_MAX_DEVICES_PER_PORT];
924 
925 #if !defined(CMT_DLL_IMPORT)
926  void readFromMessage(const void* message);
927 #endif
928 }
929 // different alignment commands for gcc / MSVS
930 #ifdef _MSC_VER
931  ;
932  #pragma pack(pop)
933 #else
934  __attribute__((__packed__)) ;
935 #endif
936 
938 
940 typedef uint32_t CmtOutputMode;
942 typedef uint64_t CmtOutputSettings;
943 
946  CmtOutputMode m_outputMode;
947  CmtOutputSettings m_outputSettings;
948 
949 #if !defined(CMT_DLL_IMPORT)
950  CmtDataFormat( const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
952  const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS)
953  : m_outputMode(mode), m_outputSettings(settings) {}
954 #endif
955 };
956 
958 typedef uint16_t CmtMtTimeStamp;
959 
960 #define CMT_MAX_FILENAME_LENGTH 512
961 
962 #define CMT_DID_BROADCAST 0x80000000
963 #define CMT_DID_MASTER 0
964 
965 
968  uint16_t m_mode;
969  uint16_t m_skipFactor;
970  uint32_t m_offset;
971 
972 #if !defined(CMT_DLL_IMPORT)
973  CmtSyncInSettings( const uint16_t mode = 0,
975  const uint16_t skip = 0,
976  const uint32_t offset = 0)
977  : m_mode(mode), m_skipFactor(skip), m_offset(offset) {}
978 #endif
979 };
980 
983  uint16_t m_mode;
984  uint16_t m_skipFactor;
985  uint32_t m_offset;
986  uint32_t m_pulseWidth;
987 
988 #if !defined(CMT_DLL_IMPORT)
989  CmtSyncOutSettings( const uint16_t mode = 0,
991  const uint16_t skip = 0,
992  const uint32_t offset = 0,
993  const uint32_t width = CMT_SYNCOUT_DEFAULT_PULSE_WIDTH) :
994  m_mode(mode), m_skipFactor(skip), m_offset(offset),
995  m_pulseWidth(width) {}
996 #endif
997 };
998 
1001 {
1002  uint32_t m_nano;
1003  uint16_t m_year;
1004  uint8_t m_month;
1005  uint8_t m_day;
1006  uint8_t m_hour;
1007  uint8_t m_minute;
1008  uint8_t m_second;
1009  uint8_t m_valid;
1010 };
1011 
1014  CmtOutputMode m_outputMode;
1015  CmtOutputSettings m_outputSettings;
1017 
1018 #if !defined(CMT_DLL_IMPORT)
1019  CmtDeviceMode( const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
1021  const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS,
1022  const uint16_t frequency = CMT_DEFAULT_SAMPLE_FREQUENCY) :
1023  m_outputMode(mode), m_outputSettings(settings),
1024  m_sampleFrequency(frequency) {}
1025 
1033  void getPeriodAndSkipFactor(uint16_t& period, uint16_t& skip) const;
1038  double getRealSampleFrequency(void) const;
1044  void setPeriodAndSkipFactor(uint16_t period, uint16_t skip);
1045 
1047  bool operator == (const CmtDeviceMode& dev) const;
1048 #endif
1049 };
1050 
1053  CmtOutputMode m_outputMode;
1054  CmtOutputSettings m_outputSettings;
1055  uint16_t m_period;
1056  uint16_t m_skip;
1057 
1058 #if !defined(CMT_DLL_IMPORT)
1059  CmtDeviceMode2( const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
1061  const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS,
1062  const uint16_t period = CMT_DEFAULT_PERIOD,
1063  const uint16_t skip = CMT_DEFAULT_SKIP) :
1064  m_outputMode(mode), m_outputSettings(settings),
1065  m_period(period), m_skip(skip) {}
1066 
1071  double getRealSampleFrequency(void) const;
1076  uint16_t getSampleFrequency(void) const;
1082  void setSampleFrequency(uint16_t freq);
1083 
1085  bool operator == (const CmtDeviceMode2& dev) const;
1086 #endif
1087 };
1088 
1089 #define CMT_MAX_SCENARIOS_IN_MT 5
1090 #define CMT_MAX_SCENARIOS 254
1091 
1093 struct CmtScenario {
1094  uint8_t m_type;
1095  uint8_t m_version;
1096  char m_label[CMT_LEN_SCENARIOLABEL+1];
1098  uint8_t m_filterMajor, m_filterMinor;
1099 };
1100 
1103 
1115 
1117 };
1118 
1119 #define CmtCallbackSelector CmtCallbackType
1120 
1125 };
1126 
1128  int32_t m_size;
1129  uint8_t m_data[CMT_MAXMSGLEN];
1130  uint16_t m_portNr;
1131 };
1132 
1134 typedef void (__cdecl * CmtCallbackFunction)(int32_t instance, int32_t callbackType, void* param, void* userParam);
1135 
1137 struct CmtPortInfo {
1138  uint32_t m_baudrate;
1139  uint32_t m_deviceId;
1140  uint16_t m_portNr;
1141  char m_portName[256];
1142 #ifdef __cplusplus
1143 # ifdef _WIN32
1144  bool operator > (const CmtPortInfo& p) const { return m_portNr > p.m_portNr; }
1147  bool operator < (const CmtPortInfo& p) const { return m_portNr < p.m_portNr; }
1149  bool operator == (const CmtPortInfo& p) const { return m_portNr == p.m_portNr; }
1151  bool operator == (const uint16_t port) const { return m_portNr == port; }
1153  bool operator == (const char *port) const { return strcmp(m_portName, port) == 0; }
1154 # else // Linux
1155  bool operator > (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) > 0; }
1158  bool operator < (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) < 0; }
1160  bool operator == (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) == 0; }
1162  bool operator == (const uint16_t port) const { (void)port; return false; }
1164  bool operator == (const char *port) const { return strcmp(m_portName, port) == 0; }
1165 # endif // ifdef _WIN32/Linux
1166 #endif
1167 };
1168 
1170  uint16_t m_data[3];
1171 };
1172 struct CmtRawData {
1173  CmtShortVector m_acc,m_gyr,m_mag;
1174  uint16_t m_temp;
1175 };
1176 struct CmtGpsPvtData { uint16_t m_pressure;
1177  uint8_t m_pressureAge;
1178  uint32_t m_itow;
1179  int32_t m_latitude;
1180  int32_t m_longitude;
1181  int32_t m_height;
1182  int32_t m_veln;
1183  int32_t m_vele;
1184  int32_t m_veld;
1185  uint32_t m_hacc;
1186  uint32_t m_vacc;
1187  uint32_t m_sacc;
1188  uint8_t m_gpsAge;
1189 };
1190 #define CmtRawGpsData CmtGpsPvtData
1191 struct CmtRawPressureData {
1192  uint16_t m_pressure;
1193  uint8_t m_pressureAge;
1194 };
1196 {
1197  uint16_t m_data;
1198 };
1199 struct CmtVector {
1200  double m_data[3];
1201 };
1202 struct CmtCalData {
1203  CmtVector m_acc,m_gyr,m_mag;
1204 };
1205 struct CmtQuat {
1206  double m_data[4];
1207 };
1208 struct CmtEuler {
1209  double m_roll;
1210  double m_pitch;
1211  double m_yaw;
1212 };
1213 struct CmtMatrix {
1214  double m_data[3][3];
1215 };
1216 
1217 #define CMT_MAX_SVINFO 16
1219  uint8_t m_id;
1223 };
1226 };
1227 
1228 typedef int64_t CmtTimeStamp;
1229 
1230 #define CMT_AUTO_SAVE_FRAMES 5000
1231 #define CMT_FILE_LAST_FRAME 0xFFFFFFFF
1232 
1233 #define CMT_BID_BROADCAST (const uint8_t)0x00
1234 #define CMT_BID_INVALID (const uint8_t)0xFE
1235 #define CMT_MID_REQEMTS (const uint8_t)0x90
1236 #define CMT_MID_EMTSDATA (const uint8_t)0x91
1237 #define CMT_EMTS_SIZE 1320
1238 
1239 #define CMT_STATUSFLAG_SELFTEST_OK 0x01
1240 #define CMT_STATUSFLAG_XKFVALID 0x02
1241 #define CMT_STATUSFLAG_GPSVALID 0x04
1242 #define CMT_STATUSFLAG_NOROTATION_MASK 0x18
1243 #define CMT_STATUSFLAG_NOROTATION 0x18
1244 #define CMT_STATUSFLAG_NOROTATION_ABORTED 0x10
1245 #define CMT_STATUSFLAG_NOROTATION_SAMPLES_REJECTED 0x08
1246 
1247 #define CMT_MAX_VPORTNAME_LEN 32
1248 
1249 #endif
A structure for storing sync in settings.
Definition: cmtdef.h:967
uint8_t m_revision
Definition: cmtdef.h:889
uint8_t m_second
Definition: cmtdef.h:1008
Definition: cmtdef.h:869
double m_yaw
The yaw (rotation around z-axis / down-up-line)
Definition: cmtdef.h:1211
A structure for storing data formats.
Definition: cmtdef.h:945
double m_pitch
The pitch (rotation around y-axis / right-left-line)
Definition: cmtdef.h:1210
uint16_t m_mode
Definition: cmtdef.h:983
Definition: cmtdef.h:876
Definition: cmtdef.h:867
Definition: cmtdef.h:860
#define CMT_SYNCOUT_DEFAULT_PULSE_WIDTH
Definition: cmtdef.h:810
CmtOutputSettings m_outputSettings
Definition: cmtdef.h:1054
uint16_t m_year
Definition: cmtdef.h:1003
uint16_t m_dataLength
Definition: cmtdef.h:913
Called when receiving a wakeup message in config mode. Advise to refresh that port cache as soon as p...
Definition: cmtdef.h:1112
Definition: cmtdef.h:878
uint16_t m_temp
Definition: cmtdef.h:1174
Not a callback function. Used to define the end of a CallbackSelector list.
Definition: cmtdef.h:1102
Definition: cmtdef.h:1202
uint32_t m_masterDeviceId
Definition: cmtdef.h:900
Called when a new CMT instance was created or an existing one is about to be destroyed. Also called once for all existing CMT instances when a plugin becomes enabled. If param is non-null, the instance is created, otherwise it is about to be destroyed. The return value of this callback is ignored.
Definition: cmtdef.h:1113
uint32_t m_itow
Definition: cmtdef.h:1178
int64_t CmtTimeStamp
Definition: cmtdef.h:1228
Definition: cmtdef.h:1124
Called when interpolation mode != 0 and missing samples are detected.
Definition: cmtdef.h:1111
Definition: cmtdef.h:1169
Definition: cmtdef.h:1208
Definition: cmtdef.h:1127
Not a callback function. Used internally for list management.
Definition: cmtdef.h:1116
uint8_t m_signalStrength
Definition: cmtdef.h:1222
CmtOutputSettings m_outputSettings
Definition: cmtdef.h:1015
CmtCallbackType
Definition: cmtdef.h:1101
int32_t m_veln
Definition: cmtdef.h:1182
#define __cdecl
Definition: cmtdef.h:51
int32_t m_veld
Definition: cmtdef.h:1184
uint16_t m_outputMode
Definition: cmtdef.h:914
uint8_t m_valid
When set to 1, the time is valid, when set to 2, the time part is valid, but the date may not be vali...
Definition: cmtdef.h:1009
uint8_t m_major
Definition: cmtdef.h:887
uint16_t m_syncinSkipFactor
Definition: cmtdef.h:904
#define CMT_MAXMSGLEN
Definition: cmtdef.h:98
CmtControlLine
Definition: cmtdef.h:853
Definition: cmtdef.h:856
Definition: cmtdef.h:875
Definition: cmtdef.h:1218
Definition: cmtdef.h:871
uint16_t m_pressure
Definition: cmtdef.h:1176
uint32_t m_offset
Offset in ns.
Definition: cmtdef.h:985
Called right after successfully switching to Measurement mode.
Definition: cmtdef.h:1105
uint32_t m_deviceId
Definition: cmtdef.h:912
Called right before switching from Measurement mode to Config mode.
Definition: cmtdef.h:1106
Definition: cmtdef.h:1176
uint32_t m_nano
Definition: cmtdef.h:1002
uint16_t m_pressure
Definition: cmtdef.h:1192
Called when a full message has been received from a port.
Definition: cmtdef.h:1109
CmtQueueMode
Definition: cmtdef.h:1121
#define CMT_DEFAULT_SAMPLE_FREQUENCY
Definition: cmtdef.h:807
Definition: cmtdef.h:1224
uint8_t m_hour
Definition: cmtdef.h:1006
uint8_t m_filterType
Definition: cmtdef.h:920
Called right before sending a GotoMeasurement message.
Definition: cmtdef.h:1104
Definition: cmtdef.h:855
uint16_t m_period
Definition: cmtdef.h:1055
uint8_t m_fwRevRevision
Definition: cmtdef.h:919
uint16_t m_sampleFrequency
Definition: cmtdef.h:1016
uint8_t m_minor
Definition: cmtdef.h:888
CmtXmSyncMode
Definition: cmtdef.h:874
Definition: cmtdef.h:862
double m_roll
The roll (rotation around x-axis / back-front-line)
Definition: cmtdef.h:1209
#define CMT_DEFAULT_PERIOD
Definition: cmtdef.h:808
CmtOutputMode m_outputMode
Definition: cmtdef.h:1053
uint32_t m_hacc
Definition: cmtdef.h:1185
uint8_t m_filterMinor
Definition: cmtdef.h:922
uint16_t m_skipFactor
Definition: cmtdef.h:969
uint8_t m_day
Definition: cmtdef.h:1005
uint8_t m_fwRevMajor
Definition: cmtdef.h:917
int32_t m_height
Definition: cmtdef.h:1181
A structure for storing scenario information.
Definition: cmtdef.h:1093
Definition: cmtdef.h:1199
uint32_t m_sacc
Definition: cmtdef.h:1187
int32_t m_longitude
Definition: cmtdef.h:1180
uint8_t m_navigationStatus
Definition: cmtdef.h:1220
Definition: cmtdef.h:879
uint8_t m_type
The type of the scenario. When set to 255 in an operation, the &#39;current&#39; scenario is used...
Definition: cmtdef.h:1094
CmtOutputMode m_outputMode
Definition: cmtdef.h:946
uint8_t m_month
Definition: cmtdef.h:1004
uint16_t m_currentScenario
Definition: cmtdef.h:916
uint32_t m_offset
Offset in ns.
Definition: cmtdef.h:970
Definition: cmtdef.h:1123
Called when a full message has been sent by a port.
Definition: cmtdef.h:1110
uint16_t m_skipFactor
Definition: cmtdef.h:984
char m_filterType
The type of the XKF filter this scenario is intended for &#39;3&#39;: XKF-3, &#39;6&#39;: XKF-6.
Definition: cmtdef.h:1097
#define CMT_LEN_SCENARIOLABEL
Definition: cmtdef.h:305
uint32_t m_vacc
Definition: cmtdef.h:1186
uint8_t m_filterMajor
Definition: cmtdef.h:921
Definition: cmtdef.h:857
uint8_t m_fwRevMinor
Definition: cmtdef.h:918
uint32_t m_deviceId
The device Id of the detected Xsens device.
Definition: cmtdef.h:1139
Provides Standard return values for Xsens functions.
uint8_t m_filterMinor
The version of the XKF filter this scenario is intended for.
Definition: cmtdef.h:1098
Called when bytes have been read from a port.
Definition: cmtdef.h:1108
uint16_t m_portNr
Definition: cmtdef.h:1130
Definition: cmtdef.h:1172
Called when a full data bundle is available and has been processed by the CMT. The first void* parame...
Definition: cmtdef.h:1107
int32_t m_size
Definition: cmtdef.h:1128
void(__cdecl * CmtCallbackFunction)(int32_t instance, int32_t callbackType, void *param, void *userParam)
Function prototype for Cmt callback functions.
Definition: cmtdef.h:1134
uint32_t m_pulseWidth
Pulse width in ns.
Definition: cmtdef.h:986
uint16_t m_syncinMode
Definition: cmtdef.h:903
Definition: cmtdef.h:854
uint16_t m_skip
Definition: cmtdef.h:1056
Definition: cmtdef.h:1205
char m_portName[256]
The port name.
Definition: cmtdef.h:1141
uint16_t m_outputSkipFactor
Definition: cmtdef.h:902
uint8_t m_minute
Definition: cmtdef.h:1007
uint8_t m_id
Definition: cmtdef.h:1219
CmtOutputSettings m_outputSettings
Definition: cmtdef.h:947
#define CMT_DEFAULT_OUTPUT_SETTINGS
Definition: cmtdef.h:801
uint8_t m_gpsAge
Definition: cmtdef.h:1188
#define CMT_DEFAULT_SKIP
Definition: cmtdef.h:809
A structure for storing the firmware version.
Definition: cmtdef.h:886
uint32_t CmtOutputMode
An output mode bit-field.
Definition: cmtdef.h:940
Definition: cmtdef.h:861
uint16_t m_data
Definition: cmtdef.h:1197
CmtVector m_mag
Definition: cmtdef.h:1203
uint16_t m_mode
Definition: cmtdef.h:968
CmtResetMethod
Definition: cmtdef.h:866
A structure for storing UTC Time values.
Definition: cmtdef.h:1000
uint16_t m_samplingPeriod
Definition: cmtdef.h:901
uint8_t m_version
The version of the scenario.
Definition: cmtdef.h:1095
uint16_t m_numberOfDevices
Definition: cmtdef.h:910
int32_t m_vele
Definition: cmtdef.h:1183
Structure containing a full device configuration as returned by the ReqConfig message.
Definition: cmtdef.h:899
uint8_t m_signalQuality
Definition: cmtdef.h:1221
A structure for storing device modes.
Definition: cmtdef.h:1013
Definition: cmtdef.h:1213
uint32_t m_outputSettings
Definition: cmtdef.h:915
Definition: cmtdef.h:1122
Definition: cmtdef.h:870
Definition: cmtdef.h:911
uint32_t m_syncinOffset
Definition: cmtdef.h:905
#define CMT_DEFAULT_OUTPUT_MODE
Definition: cmtdef.h:800
Structure for storing information about a serial port.
Definition: cmtdef.h:1137
#define CMT_MAX_DEVICES_PER_PORT
Definition: cmtdef.h:806
Called when a full data bundle is available and has been processed by the CMT. The first void* parame...
Definition: cmtdef.h:1114
int32_t m_latitude
Definition: cmtdef.h:1179
A structure for storing sync out settings.
Definition: cmtdef.h:982
Definition: cmtdef.h:877
CmtOutputMode m_outputMode
Definition: cmtdef.h:1014
uint32_t CmtDeviceId
The type of a Device Id.
Definition: cmtdef.h:883
uint8_t m_pressureAge
Definition: cmtdef.h:1177
uint16_t CmtMtTimeStamp
An MT timestamp (sample count)
Definition: cmtdef.h:958
uint16_t m_portNr
The port number.
Definition: cmtdef.h:1140
uint8_t m_pressureAge
Definition: cmtdef.h:1193
Definition: cmtdef.h:868
uint32_t m_baudrate
The baudrate at which an Xsens device was detected.
Definition: cmtdef.h:1138
CmtShortVector m_mag
Definition: cmtdef.h:1173
uint64_t CmtOutputSettings
An output settings bit-field.
Definition: cmtdef.h:942
#define CMT_MAX_SVINFO
Definition: cmtdef.h:1217
A structure for storing device modes using period and skip factor (new default)
Definition: cmtdef.h:1052
Definition: cmtdef.h:859
Definition: cmtdef.h:1195
Definition: cmtdef.h:858