cmtdef.h

Go to the documentation of this file.
00001 /*! \file
00002         \brief        Macros and types for use in the Xsens communication protocol and CMT classes
00003 
00004         This file contains useful macros for the Xsens CMT classes. These include
00005         Message Ids, sizes of messages, result/error codes, etc.
00006         
00007         The macros and enumerators in this file are either used on multiple levels (XsensResultValue)
00008         or so numerous (CMT_MID_...) that it would not be justifiable to put them in a header
00009         file of a particular level.
00010 
00011         \section FileCopyright Copyright Notice 
00012         Copyright (C) Xsens Technologies B.V., 2006.  All rights reserved.
00013 
00014         This source code is intended for use only by Xsens Technologies BV and
00015         those that have explicit written permission to use it from
00016         Xsens Technologies BV.
00017 
00018         THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00019         KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00020         IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00021         PARTICULAR PURPOSE.
00022 
00023         \section FileChangelog        Changelog
00024         \par 2006-05-01, v0.0.1
00025         \li Job Mulder:        Created Cmtdef.h
00026         \par 2006-07-21, v0.1.0
00027         \li Job Mulder:        Updated file for release 0.1.0
00028 */
00029 
00030 #ifndef _CMTDEF_H_2006_05_01
00031 #define _CMTDEF_H_2006_05_01
00032 
00033 #ifndef _CMT_MONOLITHIC
00034 #ifndef _PSTDINT_H_INCLUDED
00035 #        include "pstdint.h"
00036 #endif
00037 #endif
00038 #include <time.h>
00039 
00040 #ifdef _WIN32
00041 #else
00042 #        include <termios.h>
00043 #        include <string.h>
00044 #        ifndef        B460800
00045 #                undef        B230400
00046 #                define        B230400        0010003
00047 #                define  B460800 0010004
00048 #                define  B921600 0010007
00049 #        endif
00050 // required for gnu c++ compiler due to difference in attribute declarations
00051 #   define __cdecl __attribute__((cdecl))
00052 #   define __stdcall __attribute__((stdcall))
00053 #endif
00054 
00055 #ifndef _XSENS_STD_H_2006_09_11
00056 #        include "xsens_std.h"
00057 #endif
00058 #if !defined(_XSENS_TIME_2006_09_12) && !defined(_CMT_DLL_IMPORT)
00059 #        include "xsens_time.h"
00060 #endif
00061 
00062 #ifndef _CMT_FILE_DEF_H_2007_01_24
00063 #        include "cmtf.h"
00064 #endif
00065 
00066 //////////////////////////////////////////////////////////////////////////////////////////
00067 // Field message indices
00068 #define CMT_IND_PREAMBLE                                0
00069 #define CMT_IND_BID                                                1
00070 #define CMT_IND_MID                                                2
00071 #define CMT_IND_LEN                                                3
00072 #define CMT_IND_DATA0                                        4
00073 #define CMT_IND_LENEXTH                                        4
00074 #define CMT_IND_LENEXTL                                        5
00075 #define CMT_IND_DATAEXT0                                6
00076 
00077 #define CMT_PREAMBLE                                        0xFA
00078 #define CMT_BID_MASTER                                        0xFF
00079 #define CMT_BID_MT                                                0x01
00080 #define CMT_EXTLENCODE                                        0xFF
00081 
00082 #define CMT_LEN_MSGHEADER                                4
00083 #define CMT_LEN_MSGEXTHEADER                        6
00084 #define CMT_LEN_MSGHEADERCS                                5
00085 #define CMT_LEN_MSGEXTHEADERCS                        7
00086 #define CMT_LEN_CHECKSUM                                1
00087 #define CMT_LEN_UNSIGSHORT                                2
00088 #define CMT_LEN_UNSIGINT                                4
00089 #define CMT_LEN_FLOAT                                        4
00090 
00091 // Maximum message/data length
00092 #define CMT_MAXDATALEN                                        8192
00093 #define CMT_MAXSHORTDATALEN                                254
00094 #define CMT_MAXMSGLEN                                        (CMT_MAXDATALEN+7)
00095 #define CMT_MAXSHORTMSGLEN                                (CMT_MAXSHORTDATALEN+5)
00096 #define CMT_MAXGARBAGE                                        (CMT_MAXMSGLEN+1)
00097 
00098 
00099 // DID Type (high nibble)
00100 #define CMT_DID_TYPEH_MASK                                0x00F00000
00101 #define CMT_DID_TYPEL_MASK                                0x000F0000
00102 #define CMT_DID_TYPEH_MT                                0x00000000
00103 #define CMT_DID_TYPEH_XM                                0x00100000
00104 #define CMT_DID_TYPEH_MTI_MTX                        0x00300000
00105 #define CMT_DID_TYPEH_MTIG                                0x00500000
00106 #define CMT_DID_TYPE_MASK                                0x00FF0000
00107 #define CMT_DID_TYPE_MASK_MT_232                0x00300000
00108 #define CMT_DID_TYPE_MASK_MT_422                0x00310000
00109 #define CMT_DID_TYPE_MASK_MT_XM                        0x00020000
00110 #define CMT_DID_TYPE_MASK_MT_485                0x00330000
00111 
00112 // All Message identifiers
00113 // WakeUp state messages
00114 #define CMT_MID_WAKEUP                                        0x3E
00115 #define CMT_MID_WAKEUPACK                                0x3F
00116 
00117 // Config state messages
00118 #define CMT_MID_REQDID                                        0x00
00119 #define CMT_MID_DEVICEID                                0x01
00120 #define CMT_LEN_DEVICEID                                4
00121 #define CMT_MID_INITBUS                                        0x02
00122 #define CMT_MID_INITBUSRESULTS                        0x03
00123 #define CMT_LEN_INITBUSRESULTS                        4
00124 #define CMT_MID_REQPERIOD                                0x04
00125 #define CMT_MID_REQPERIODACK                        0x05
00126 #define CMT_LEN_PERIOD                                        2
00127 #define CMT_MID_SETPERIOD                                0x04
00128 #define CMT_MID_SETPERIODACK                        0x05
00129 // XbusMaster
00130 #define CMT_MID_SETBID                                        0x06
00131 #define CMT_MID_SETBIDACK                                0x07
00132 #define CMT_MID_AUTOSTART                                0x06
00133 #define CMT_MID_AUTOSTARTACK                        0x07
00134 #define CMT_MID_BUSPWR                                        0x08
00135 #define CMT_LEN_BUSPWR                                        2
00136 #define CMT_MID_BUSPWRACK                                0x09
00137 // End XbusMaster
00138 #define CMT_MID_REQDATALENGTH                        0x0A
00139 #define CMT_MID_DATALENGTH                                0x0B
00140 #define CMT_LEN_DATALENGTH                                2
00141 #define CMT_MID_REQCONFIGURATION                0x0C
00142 #define CMT_MID_CONFIGURATION                        0x0D
00143 #define CMT_LEN_CONFIGURATION                        118
00144 #define CMT_MID_RESTOREFACTORYDEF                0x0E
00145 #define CMT_MID_RESTOREFACTORYDEFACK        0x0F
00146 
00147 #define CMT_MID_GOTOMEASUREMENT                        0x10
00148 #define CMT_MID_GOTOMEASUREMENTACK                0x11
00149 #define CMT_MID_REQFWREV                                0x12
00150 #define CMT_MID_FIRMWAREREV                                0x13
00151 #define CMT_LEN_FIRMWAREREV                                3
00152 // XbusMaster
00153 #define CMT_MID_REQBTDISABLE                        0x14
00154 #define CMT_MID_REQBTDISABLEACK                        0x15
00155 #define CMT_LEN_BTDISABLE                                1
00156 #define CMT_MID_DISABLEBT                                0x14
00157 #define CMT_MID_DISABLEBTACK                        0x15
00158 #define CMT_MID_REQOPMODE                                0x16
00159 #define CMT_MID_REQOPMODEACK                        0x17
00160 #define CMT_LEN_OPMODE                                        1
00161 #define CMT_MID_SETOPMODE                                0x16
00162 #define CMT_MID_SETOPMODEACK                        0x17
00163 // End XbusMaster
00164 #define CMT_MID_REQBAUDRATE                                0x18
00165 #define CMT_MID_REQBAUDRATEACK                        0x19
00166 #define CMT_LEN_BAUDRATE                                1
00167 #define CMT_MID_SETBAUDRATE                                0x18
00168 #define CMT_MID_SETBAUDRATEACK                        0x19
00169 // XbusMaster
00170 #define CMT_MID_REQSYNCMODE                                0x1A
00171 #define CMT_MID_REQSYNCMODEACK                        0x1B
00172 #define CMT_LEN_SYNCMODE                                1
00173 #define CMT_MID_SETSYNCMODE                                0x1A
00174 #define CMT_MID_SETSYNCMODEACK                        0x1B
00175 // End XbusMaster
00176 #define CMT_MID_REQPRODUCTCODE                        0x1C
00177 #define CMT_MID_PRODUCTCODE                                0x1D
00178 #define CMT_LEN_PRODUCTCODE                                20
00179 
00180 #define CMT_MID_REQPROCESSINGFLAGS                0x20
00181 #define CMT_MID_REQPROCESSINGFLAGSACK        0x21
00182 #define CMT_LEN_PROCESSINGFLAGS                        2
00183 #define CMT_MID_SETPROCESSINGFLAGS                0x20
00184 #define CMT_MID_SETPROCESSINGFLAGSACK        0x21
00185 
00186 // XbusMaster
00187 #define CMT_MID_XMPWROFF                                0x44
00188 #define CMT_LEN_XMPWROFF                                0
00189 // End XbusMaster
00190 
00191 #define CMT_MID_REQOUTPUTMODE                        0xD0
00192 #define CMT_MID_REQOUTPUTMODEACK                0xD1
00193 #define CMT_LEN_OUTPUTMODE                                 2
00194 #define CMT_MID_SETOUTPUTMODE                        0xD0
00195 #define CMT_MID_SETOUTPUTMODEACK                0xD1
00196 
00197 #define CMT_MID_REQOUTPUTSETTINGS                0xD2
00198 #define CMT_MID_REQOUTPUTSETTINGSACK        0xD3
00199 #define CMT_LEN_OUTPUTSETTINGS                         4
00200 #define CMT_MID_SETOUTPUTSETTINGS                0xD2
00201 #define CMT_MID_SETOUTPUTSETTINGSACK        0xD3
00202 
00203 #define CMT_MID_REQOUTPUTSKIPFACTOR                0xD4
00204 #define CMT_MID_REQOUTPUTSKIPFACTORACK        0xD5
00205 #define CMT_LEN_OUTPUTSKIPFACTOR                2
00206 #define CMT_MID_SETOUTPUTSKIPFACTOR                0xD4
00207 #define CMT_MID_SETOUTPUTSKIPFACTORACK        0xD5
00208 
00209 #define CMT_MID_REQSYNCINSETTINGS                0xD6
00210 #define CMT_MID_REQSYNCINSETTINGSACK        0xD7
00211 #define CMT_LEN_SYNCINMODE                                2
00212 #define CMT_LEN_SYNCINSKIPFACTOR                2
00213 #define CMT_LEN_SYNCINOFFSET                        4
00214 #define CMT_MID_SETSYNCINSETTINGS                0xD6
00215 #define CMT_MID_SETSYNCINSETTINGSACK        0xD7
00216 
00217 #define CMT_MID_REQSYNCOUTSETTINGS                0xD8
00218 #define CMT_MID_REQSYNCOUTSETTINGSACK        0xD9
00219 #define CMT_LEN_SYNCOUTMODE                                2
00220 #define CMT_LEN_SYNCOUTSKIPFACTOR                2
00221 #define CMT_LEN_SYNCOUTOFFSET                        4
00222 #define CMT_LEN_SYNCOUTPULSEWIDTH                4
00223 #define CMT_MID_SETSYNCOUTSETTINGS                0xD8
00224 #define CMT_MID_SETSYNCOUTSETTINGSACK        0xD9
00225 
00226 #define CMT_MID_REQERRORMODE                        0xDA
00227 #define CMT_MID_REQERRORMODEACK                        0xDB
00228 #define CMT_LEN_ERRORMODE                                2
00229 #define CMT_MID_SETERRORMODE                        0xDA
00230 #define CMT_MID_SETERRORMODEACK                        0xDB
00231 
00232 #define CMT_MID_REQTRANSMITDELAY                0xDC
00233 #define CMT_MID_REQTRANSMITDELAYACK                0xDD
00234 #define CMT_LEN_TRANSMITDELAY                        2
00235 #define CMT_MID_SETTRANSMITDELAY                0xDC
00236 #define CMT_MID_SETTRANSMITDELAYACK                0xDD        
00237 
00238 #define CMT_MID_REQOBJECTALIGNMENT                0xE0        
00239 #define CMT_MID_REQOBJECTALIGNMENTACK        0xE1
00240 #define CMT_LEN_OBJECTALIGNMENT                        36
00241 #define CMT_MID_SETOBJECTALIGNMENT                0xE0        
00242 #define CMT_MID_SETOBJECTALIGNMENTACK        0xE1
00243 
00244 // Xbus Master
00245 #define CMT_MID_REQXMERRORMODE                        0x82
00246 #define CMT_MID_REQXMERRORMODEACK                0x83
00247 #define CMT_LEN_XMERRORMODE                                2
00248 #define CMT_MID_SETXMERRORMODE                        0x82
00249 #define CMT_MID_SETXMERRORMODEACK                0x83
00250 
00251 #define CMT_MID_REQBUFFERSIZE                        0x84
00252 #define CMT_MID_REQBUFFERSIZEACK                0x85
00253 #define CMT_LEN_BUFFERSIZE                                2
00254 #define CMT_MID_SETBUFFERSIZE                        0x84
00255 #define CMT_MID_SETBUFFERSIZEACK                0x85                        
00256 // End Xbus Master
00257 
00258 #define CMT_MID_REQHEADING                                0x82
00259 #define CMT_MID_REQHEADINGACK                        0x83
00260 #define CMT_LEN_HEADING                                         4
00261 #define CMT_MID_SETHEADING                                0x82
00262 #define CMT_MID_SETHEADINGACK                        0x83
00263 
00264 #define CMT_MID_REQMAGNETICDECLINATION                0x6A
00265 #define CMT_MID_REQMAGNETICDECLINATIONACK        0x6B
00266 #define CMT_LEN_MAGNETICDECLINATION                         4
00267 #define CMT_MID_SETMAGNETICDECLINATION                0x6A
00268 #define CMT_MID_SETMAGNETICDECLINATIONACK        0x6B
00269 
00270 #define CMT_MID_REQLOCATIONID                        0x84
00271 #define CMT_MID_REQLOCATIONIDACK                0x85
00272 #define CMT_LEN_LOCATIONID                                2
00273 #define CMT_MID_SETLOCATIONID                        0x84
00274 #define CMT_MID_SETLOCATIONIDACK                0x85
00275 
00276 #define CMT_MID_REQEXTOUTPUTMODE                0x86
00277 #define CMT_MID_REQEXTOUTPUTMODEACK                0x87
00278 #define CMT_LEN_EXTOUTPUTMODE                        2
00279 #define CMT_MID_SETEXTOUTPUTMODE                0x86
00280 #define CMT_MID_SETEXTOUTPUTMODEACK                0x87
00281 
00282 // XbusMaster
00283 #define CMT_MID_REQBATLEVEL                                0x88
00284 #define CMT_MID_BATLEVEL                                0x89
00285 // End XbusMaster
00286 
00287 #define CMT_MID_REQINITTRACKMODE                0x88
00288 #define CMT_MID_REQINITTRACKMODEACK                0x89
00289 #define CMT_LEN_INITTRACKMODE                        2
00290 #define CMT_MID_SETINITTRACKMODE                0x88
00291 #define CMT_MID_SETINITTRACKMODEACK                0x89
00292 
00293 // obsolete
00294 //#define CMT_MID_STOREFILTERSTATE                0x8A
00295 //#define CMT_LEN_STOREFILTERSTATE                0
00296 //#define CMT_MID_STOREFILTERSTATEACK        0x8B
00297 // new definition
00298 #define CMT_MID_STOREXKFSTATE                        0x8A
00299 #define CMT_LEN_STOREXKFSTATE                        0
00300 #define CMT_MID_STOREXKFSTATEACK                0x8B
00301 
00302 #define CMT_MID_REQUTCTIME                                0x60
00303 #define CMT_MID_UTCTIME                                        0x61
00304 #define CMT_LEN_UTCTIME                                        12
00305 
00306 #define CMT_LEN_SCENARIOLABEL                        20
00307 #define CMT_LEN_SCENARIOFULL                        (1+1+CMT_LEN_SCENARIOLABEL)
00308 #define        CMT_MID_REQAVAILABLESCENARIOS        0x62
00309 #define CMT_MID_AVAILABLESCENARIOS                0x63
00310 #define CMT_LEN_AVAILABLESCENARIOS                (CMT_MAX_SCENARIOS_IN_MT*CMT_LEN_SCENARIOFULL)
00311 
00312 #define CMT_MID_REQSCENARIO                                0x64
00313 #define CMT_MID_REQSCENARIOACK                        0x65
00314 #define CMT_LEN_REQSCENARIOACK                        2
00315 #define CMT_MID_SETSCENARIO                                0x64
00316 #define CMT_MID_SETSCENARIOACK                        0x65
00317 #define CMT_LEN_SETSCENARIO                                1
00318 
00319 #define CMT_MID_REQGRAVITYMAGNITUDE                0x66
00320 #define CMT_MID_REQGRAVITYMAGNITUDEACK        0x67
00321 #define CMT_MID_SETGRAVITYMAGNITUDE                0x66
00322 #define CMT_MID_SETGRAVITYMAGNITUDEACK        0x67
00323 #define CMT_LEN_GRAVITYMAGNITUDE                4
00324 
00325 #define CMT_MID_REQGPSLEVERARM                        0x68
00326 #define CMT_MID_REQGPSLEVERARMACK                0x69
00327 #define CMT_MID_SETGPSLEVERARM                        0x68
00328 #define CMT_MID_SETGPSLEVERARMACK                0x69
00329 #define CMT_LEN_GPSLEVERARM                                12
00330 
00331 #define CMT_MID_REQLATLONALT                        0x6E
00332 #define CMT_MID_REQLATLONALTACK                        0x6F
00333 #define CMT_LEN_LATLONALT                                18
00334 #define CMT_MID_SETLATLONALT                        0x6E
00335 #define CMT_MID_SETLATLONALTACK                        0x6F
00336 
00337 // Measurement state
00338 #define CMT_MID_GOTOCONFIG                                0x30
00339 #define CMT_MID_GOTOCONFIGACK                        0x31
00340 #define CMT_MID_BUSDATA                                        0x32
00341 #define CMT_MID_MTDATA                                        0x32
00342 
00343 #define CMT_MID_SETNOROTATION                        0x22
00344 #define CMT_MID_SETNOROTATIONACK                0x23
00345 #define CMT_LEN_SETNOROTATION                        2
00346 
00347 // Manual
00348 #define CMT_MID_PREPAREDATA                                0x32
00349 #define CMT_MID_REQDATA                                        0x34
00350 #define CMT_MID_REQDATAACK                                0x35
00351 
00352 // MTData defines 
00353 // Length of data blocks in bytes
00354 #define CMT_LEN_RAWDATA                                        20
00355 #define CMT_LEN_CALIBDATA                                36
00356 #define CMT_LEN_CALIB_ACCDATA                        12
00357 #define CMT_LEN_CALIB_GYRDATA                        12
00358 #define CMT_LEN_CALIB_MAGDATA                        12
00359 #define CMT_LEN_ORIENT_QUATDATA                        16
00360 #define CMT_LEN_ORIENT_EULERDATA                12
00361 #define CMT_LEN_ORIENT_MATRIXDATA                36
00362 #define CMT_LEN_SAMPLECNT                                2
00363 #define CMT_LEN_TEMPDATA                                4
00364 
00365 // Length of data blocks in floats
00366 #define CMT_LEN_CALIBDATA_FLT                        9
00367 #define CMT_LEN_TEMPDATA_FLT                        1
00368 #define CMT_LEN_ORIENT_QUATDATA_FLT                4
00369 #define CMT_LEN_ORIENT_EULERDATA_FLT        3
00370 #define CMT_LEN_ORIENT_MATRIXDATA_FLT        9
00371 
00372 // Indices of fields in DATA field of MTData message in bytes
00373 // use in combination with LEN_CALIB etc
00374 // Un-calibrated raw data
00375 #define CMT_IND_RAW_ACCX                                0
00376 #define CMT_IND_RAW_ACCY                                2
00377 #define CMT_IND_RAW_ACCZ                                4
00378 #define CMT_IND_RAW_GYRX                                6
00379 #define CMT_IND_RAW_GYRY                                8
00380 #define CMT_IND_RAW_GYRZ                                10
00381 #define CMT_IND_RAW_MAGX                                12
00382 #define CMT_IND_RAW_MAGY                                14
00383 #define CMT_IND_RAW_MAGZ                                16
00384 #define CMT_IND_RAW_TEMP                                18
00385 // Calibrated data
00386 #define CMT_IND_CALIB_ACCX                                0
00387 #define CMT_IND_CALIB_ACCY                                4
00388 #define CMT_IND_CALIB_ACCZ                                8
00389 #define CMT_IND_CALIB_GYRX                                12
00390 #define CMT_IND_CALIB_GYRY                                16
00391 #define CMT_IND_CALIB_GYRZ                                20
00392 #define CMT_IND_CALIB_MAGX                                24
00393 #define CMT_IND_CALIB_MAGY                                28
00394 #define CMT_IND_CALIB_MAGZ                                32
00395 // Orientation data - quat
00396 #define CMT_IND_ORIENT_Q0                                0
00397 #define CMT_IND_ORIENT_Q1                                4
00398 #define CMT_IND_ORIENT_Q2                                8
00399 #define CMT_IND_ORIENT_Q3                                12
00400 // Orientation data - euler
00401 #define CMT_IND_ORIENT_ROLL                                0
00402 #define CMT_IND_ORIENT_PITCH                        4
00403 #define CMT_IND_ORIENT_YAW                                8
00404 // Orientation data - matrix
00405 #define CMT_IND_ORIENT_A                                0
00406 #define CMT_IND_ORIENT_B                                4
00407 #define CMT_IND_ORIENT_C                                8
00408 #define CMT_IND_ORIENT_D                                12
00409 #define CMT_IND_ORIENT_E                                16
00410 #define CMT_IND_ORIENT_F                                20
00411 #define CMT_IND_ORIENT_G                                24
00412 #define CMT_IND_ORIENT_H                                28
00413 #define CMT_IND_ORIENT_I                                32
00414 // Orientation data - euler
00415 #define CMT_IND_SAMPLECNTH                                0
00416 #define CMT_IND_SAMPLECNTL                                1
00417 
00418 // Indices of fields in DATA field of MTData message
00419 // Un-calibrated raw data
00420 #define CMT_FLDNUM_RAW_ACCX                                0
00421 #define CMT_FLDNUM_RAW_ACCY                                1
00422 #define CMT_FLDNUM_RAW_ACCZ                                2
00423 #define CMT_FLDNUM_RAW_GYRX                                3
00424 #define CMT_FLDNUM_RAW_GYRY                                4
00425 #define CMT_FLDNUM_RAW_GYRZ                                5
00426 #define CMT_FLDNUM_RAW_MAGX                                6
00427 #define CMT_FLDNUM_RAW_MAGY                                7
00428 #define CMT_FLDNUM_RAW_MAGZ                                8
00429 #define CMT_FLDNUM_RAW_TEMP                                9
00430 // Calibrated data
00431 #define CMT_FLDNUM_CALIB_ACCX                        0
00432 #define CMT_FLDNUM_CALIB_ACCY                        1
00433 #define CMT_FLDNUM_CALIB_ACCZ                        2
00434 #define CMT_FLDNUM_CALIB_GYRX                        3
00435 #define CMT_FLDNUM_CALIB_GYRY                        4
00436 #define CMT_FLDNUM_CALIB_GYRZ                        5
00437 #define CMT_FLDNUM_CALIB_MAGX                        6
00438 #define CMT_FLDNUM_CALIB_MAGY                        7
00439 #define CMT_FLDNUM_CALIB_MAGZ                        8
00440 // Orientation data - quat
00441 #define CMT_FLDNUM_ORIENT_Q0                        0
00442 #define CMT_FLDNUM_ORIENT_Q1                        1
00443 #define CMT_FLDNUM_ORIENT_Q2                        2
00444 #define CMT_FLDNUM_ORIENT_Q3                        3
00445 // Orientation data - euler
00446 #define CMT_FLDNUM_ORIENT_ROLL                        0
00447 #define CMT_FLDNUM_ORIENT_PITCH                        1
00448 #define CMT_FLDNUM_ORIENT_YAW                        2
00449 // Orientation data - matrix
00450 #define CMT_FLDNUM_ORIENT_A                                0
00451 #define CMT_FLDNUM_ORIENT_B                                1
00452 #define CMT_FLDNUM_ORIENT_C                                2
00453 #define CMT_FLDNUM_ORIENT_D                                3
00454 #define CMT_FLDNUM_ORIENT_E                                4
00455 #define CMT_FLDNUM_ORIENT_F                                5
00456 #define CMT_FLDNUM_ORIENT_G                                6
00457 #define CMT_FLDNUM_ORIENT_H                                7
00458 #define CMT_FLDNUM_ORIENT_I                                8
00459 // Length
00460 // Uncalibrated raw data
00461 #define CMT_LEN_RAW_ACCX                                2
00462 #define CMT_LEN_RAW_ACCY                                2
00463 #define CMT_LEN_RAW_ACCZ                                2
00464 #define CMT_LEN_RAW_GYRX                                2
00465 #define CMT_LEN_RAW_GYRY                                2
00466 #define CMT_LEN_RAW_GYRZ                                2
00467 #define CMT_LEN_RAW_MAGX                                2
00468 #define CMT_LEN_RAW_MAGY                                2
00469 #define CMT_LEN_RAW_MAGZ                                2
00470 #define CMT_LEN_RAW_TEMP                                2
00471 // Calibrated data
00472 #define CMT_LEN_CALIB_ACCX                                4
00473 #define CMT_LEN_CALIB_ACCY                                4
00474 #define CMT_LEN_CALIB_ACCZ                                4
00475 #define CMT_LEN_CALIB_GYRX                                4
00476 #define CMT_LEN_CALIB_GYRY                                4
00477 #define CMT_LEN_CALIB_GYRZ                                4
00478 #define CMT_LEN_CALIB_MAGX                                4
00479 #define CMT_LEN_CALIB_MAGY                                4
00480 #define CMT_LEN_CALIB_MAGZ                                4
00481 // Orientation data - quat
00482 #define CMT_LEN_ORIENT_Q0                                4
00483 #define CMT_LEN_ORIENT_Q1                                4
00484 #define CMT_LEN_ORIENT_Q2                                4
00485 #define CMT_LEN_ORIENT_Q3                                4
00486 // Orientation data - euler
00487 #define CMT_LEN_ORIENT_ROLL                                4
00488 #define CMT_LEN_ORIENT_PITCH                        4
00489 #define CMT_LEN_ORIENT_YAW                                4
00490 // Orientation data - matrix
00491 #define CMT_LEN_ORIENT_A                                4
00492 #define CMT_LEN_ORIENT_B                                4
00493 #define CMT_LEN_ORIENT_C                                4
00494 #define CMT_LEN_ORIENT_D                                4
00495 #define CMT_LEN_ORIENT_E                                4
00496 #define CMT_LEN_ORIENT_F                                4
00497 #define CMT_LEN_ORIENT_G                                4
00498 #define CMT_LEN_ORIENT_H                                4
00499 #define CMT_LEN_ORIENT_I                                4
00500 
00501 // Defines for getDataValue
00502 #define CMT_VALUE_RAW_ACC                                0
00503 #define CMT_VALUE_RAW_GYR                                1
00504 #define CMT_VALUE_RAW_MAG                                2
00505 #define CMT_VALUE_RAW_TEMP                                3
00506 #define CMT_VALUE_CALIB_ACC                                4
00507 #define CMT_VALUE_CALIB_GYR                                5
00508 #define CMT_VALUE_CALIB_MAG                                6
00509 #define CMT_VALUE_ORIENT_QUAT                        7
00510 #define CMT_VALUE_ORIENT_EULER                        8
00511 #define CMT_VALUE_ORIENT_MATRIX                        9
00512 #define CMT_VALUE_SAMPLECNT                                10
00513 #define CMT_VALUE_TEMP                                        11
00514 
00515 #define CMT_INVALIDSETTINGVALUE                        0xFFFFFFFF
00516 
00517 
00518 // Valid in all states
00519 #define CMT_MID_RESET                                        0x40
00520 #define CMT_MID_RESETACK                                0x41
00521 #define CMT_MID_ERROR                                        0x42
00522 // XbusMaster
00523 #define CMT_MID_XMPWROFF                                0x44
00524 // End XbusMaster
00525 
00526 #define CMT_MID_REQFILTERSETTINGS                0xA0
00527 #define CMT_MID_REQFILTERSETTINGSACK        0xA1
00528 #define CMT_LEN_FILTERSETTINGS                        4
00529 #define CMT_MID_SETFILTERSETTINGS                0xA0
00530 #define CMT_MID_SETFILTERSETTINGSACK        0xA1
00531 #define CMT_MID_REQAMD                                        0xA2
00532 #define CMT_MID_REQAMDACK                                0xA3
00533 #define CMT_LEN_AMD                                                2
00534 #define CMT_MID_SETAMD                                        0xA2
00535 #define CMT_MID_SETAMDACK                                0xA3
00536 #define CMT_MID_RESETORIENTATION                0xA4
00537 #define CMT_MID_RESETORIENTATIONACK                0xA5
00538 #define CMT_LEN_RESETORIENTATION                2
00539 
00540 #define CMT_MID_REQGPSSTATUS                        0xA6
00541 #define CMT_MID_GPSSTATUS                                0xA7
00542 #define CMT_LEN_GPSSTATUS                                (1+5*16)
00543 
00544 // Baudrate defines for SetBaudrate message
00545 #define CMT_BAUDCODE_4K8                                0x0B
00546 #define CMT_BAUDCODE_9K6                                0x09
00547 //        #define CMT_BAUDCODE_14K4                                0x08
00548 #define CMT_BAUDCODE_19K2                                0x07
00549 //        #define CMT_BAUDCODE_28K8                                0x06
00550 #define CMT_BAUDCODE_38K4                                0x05
00551 #define CMT_BAUDCODE_57K6                                0x04
00552 //        #define CMT_BAUDCODE_76K8                                0x03
00553 #define CMT_BAUDCODE_115K2                                0x02
00554 #define CMT_BAUDCODE_230K4                                0x01
00555 #define CMT_BAUDCODE_460K8                                0x00
00556 #define CMT_BAUDCODE_921K6_ALT                        0x0A                // only usable from FW 2.4.6
00557 #define CMT_BAUDCODE_921K6                                0x80
00558 
00559 // Xbus protocol error codes (Error)
00560 #define CMT_ERROR_NOBUSCOMM                                0x01
00561 #define CMT_ERROR_BUSNOTREADY                        0x02
00562 #define CMT_ERROR_PERIODINVALID                        0x03
00563 #define CMT_ERROR_MESSAGEINVALID                0x04
00564 #define CMT_ERROR_INITOFBUSFAILED1                0x10
00565 #define CMT_ERROR_INITOFBUSFAILED2                0x11
00566 #define CMT_ERROR_INITOFBUSFAILED3                0x12
00567 #define CMT_ERROR_SETBIDPROCFAILED1                0x14
00568 #define CMT_ERROR_SETBIDPROCFAILED2                0x15
00569 #define CMT_ERROR_MEASUREMENTFAILED1        0x18
00570 #define CMT_ERROR_MEASUREMENTFAILED2        0x19
00571 #define CMT_ERROR_MEASUREMENTFAILED3        0x1A
00572 #define CMT_ERROR_MEASUREMENTFAILED4        0x1B
00573 #define CMT_ERROR_MEASUREMENTFAILED5        0x1C
00574 #define CMT_ERROR_MEASUREMENTFAILED6        0x1D
00575 #define CMT_ERROR_TIMEROVERFLOW                        0x1E
00576 #define CMT_ERROR_BAUDRATEINVALID                0x20
00577 #define CMT_ERROR_PARAMETERINVALID                0x21
00578 #define CMT_ERROR_MEASUREMENTFAILED7        0x23
00579 
00580 // Error modes (SetErrorMode)
00581 #define CMT_ERRORMODE_IGNORE                                        0x0000
00582 #define CMT_ERRORMODE_INCSAMPLECNT                                0x0001
00583 #define CMT_ERRORMODE_INCSAMPLECNT_SENDERROR        0x0002
00584 #define CMT_ERRORMODE_SENDERROR_GOTOCONFIG                0x0003
00585 
00586 // Configuration message defines
00587 #define CMT_CONF_MASTERDID                                0
00588 #define CMT_CONF_PERIOD                                        4
00589 #define CMT_CONF_OUTPUTSKIPFACTOR                6
00590 #define CMT_CONF_SYNCIN_MODE                        8
00591 #define CMT_CONF_SYNCIN_SKIPFACTOR                10
00592 #define CMT_CONF_SYNCIN_OFFSET                        12
00593 #define CMT_CONF_DATE                                        16
00594 #define CMT_CONF_TIME                                        24
00595 #define CMT_CONF_NUMDEVICES                                96
00596 // Configuration sensor block properties
00597 #define CMT_CONF_DID                                        98
00598 #define CMT_CONF_DATALENGTH                                102
00599 #define CMT_CONF_OUTPUTMODE                                104
00600 #define CMT_CONF_OUTPUTSETTINGS                        106
00601 #define CMT_CONF_BLOCKLEN                                20
00602 // To calculate the offset in data field for output mode of sensor #2 use
00603 //                CONF_OUTPUTMODE + 1*CONF_BLOCKLEN
00604 #define CMT_CONF_MASTERDIDLEN                        4
00605 #define CMT_CONF_PERIODLEN                                2
00606 #define CMT_CONF_OUTPUTSKIPFACTORLEN        2
00607 #define CMT_CONF_SYNCIN_MODELEN                        2
00608 #define CMT_CONF_SYNCIN_SKIPFACTORLEN        2
00609 #define CMT_CONF_SYNCIN_OFFSETLEN                4
00610 #define CMT_CONF_DATELEN                                8
00611 #define CMT_CONF_TIMELEN                                8
00612 #define CMT_CONF_RESERVED_CLIENTLEN                32
00613 #define CMT_CONF_RESERVED_HOSTLEN                32
00614 #define CMT_CONF_NUMDEVICESLEN                        2
00615 // Configuration sensor block properties
00616 #define CMT_CONF_DIDLEN                                        4
00617 #define CMT_CONF_DATALENGTHLEN                        2
00618 #define CMT_CONF_OUTPUTMODELEN                        2
00619 #define CMT_CONF_OUTPUTSETTINGSLEN                4
00620 
00621 // Clock frequency for offset & pulse width
00622 #define CMT_SYNC_CLOCKFREQMHZ                        29.4912
00623 #define CMT_SYNC_CLOCK_NS_TO_TICKS                (CMT_SYNC_CLOCKFREQMHZ * 1.0e-3)
00624 #define CMT_SYNC_CLOCK_TICKS_TO_NS                (1.0e3 / CMT_SYNC_CLOCKFREQMHZ)
00625 
00626 // SyncIn params
00627 #define CMT_PARAM_SYNCIN_MODE                        0x00
00628 #define CMT_PARAM_SYNCIN_SKIPFACTOR                0x01
00629 #define CMT_PARAM_SYNCIN_OFFSET                        0x02
00630 
00631 // SyncIn mode
00632 #define CMT_SYNCIN_DISABLED                                0x0000
00633 #define CMT_SYNCIN_EDGE_RISING                        0x0001
00634 #define CMT_SYNCIN_EDGE_FALLING                        0x0002
00635 #define CMT_SYNCIN_EDGE_BOTH                        0x0003
00636 #define CMT_SYNCIN_EDGE_MASK                        0x0003
00637 #define CMT_SYNCIN_TYPE_DOSAMPLING                0x0000
00638 #define CMT_SYNCIN_TYPE_SENDLASTDATA        0x0004
00639 #define CMT_SYNCIN_TYPE_CLOCK                        0x0010
00640 #define CMT_SYNCIN_TYPE_MASK                        0x001C
00641 
00642 // SyncOut params
00643 #define CMT_PARAM_SYNCOUT_MODE                        0x00
00644 #define CMT_PARAM_SYNCOUT_SKIPFACTOR        0x01
00645 #define CMT_PARAM_SYNCOUT_OFFSET                0x02
00646 #define CMT_PARAM_SYNCOUT_PULSEWIDTH        0x03
00647 
00648 // SyncOut mode
00649 #define CMT_SYNCOUT_DISABLED                0x0000
00650 #define CMT_SYNCOUT_TYPE_TOGGLE                0x0001
00651 #define CMT_SYNCOUT_TYPE_PULSE                0x0002
00652 #define CMT_SYNCOUT_POL_NEG                        0x0000
00653 #define CMT_SYNCOUT_POL_POS                        0x0010
00654 #define CMT_SYNCOUT_TYPE_MASK                0x000F
00655 #define CMT_SYNCOUT_POL_MASK                0x0010
00656 
00657 // OutputModes
00658 #define CMT_OUTPUTMODE_MT9                                0x8000
00659 #define CMT_OUTPUTMODE_XM                                0x0000
00660 #define CMT_OUTPUTMODE_RAW                                0x4000
00661 //#define CMT_OUTPUTMODE_RAWGPSPRINT                0x1000        // Obsolete. Use CMT_OUTPUTMODE_GPSPVT_PRESSURE instead
00662 #define CMT_OUTPUTMODE_GPSPVT_PRESSURE        0x1000
00663 #define CMT_OUTPUTMODE_TEMP                                0x0001
00664 #define CMT_OUTPUTMODE_CALIB                        0x0002
00665 #define CMT_OUTPUTMODE_ORIENT                        0x0004
00666 #define CMT_OUTPUTMODE_AUXILIARY                0x0008
00667 #define CMT_OUTPUTMODE_POSITION                        0x0010
00668 #define CMT_OUTPUTMODE_VELOCITY                        0x0020
00669 #define CMT_OUTPUTMODE_STATUS                        0x0800
00670 
00671 
00672 // CmtOutputSettings
00673 #define CMT_OUTPUTSETTINGS_XM                                                0x00000001
00674 #define CMT_OUTPUTSETTINGS_TIMESTAMP_NONE                        0x00000000
00675 #define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT                0x00000001
00676 #define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLEUTC                0x00000002
00677 #define CMT_OUTPUTSETTINGS_ORIENTMODE_QUATERNION        0x00000000
00678 #define CMT_OUTPUTSETTINGS_ORIENTMODE_EULER                        0x00000004
00679 #define CMT_OUTPUTSETTINGS_ORIENTMODE_MATRIX                0x00000008
00680 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYRMAG                0x00000000
00681 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACC                        0x00000060
00682 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYR                        0x00000040
00683 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCMAG                        0x00000020
00684 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYR                        0x00000050
00685 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYRMAG                        0x00000010
00686 #define CMT_OUTPUTSETTINGS_CALIBMODE_MAG                        0x00000030
00687 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYRMAG_MASK        0x00000070
00688 #define CMT_OUTPUTSETTINGS_DATAFORMAT_FLOAT                        0x00000000
00689 #define CMT_OUTPUTSETTINGS_DATAFORMAT_F1220                        0x00000100
00690 #define CMT_OUTPUTSETTINGS_DATAFORMAT_FP1632                0x00000200
00691 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN1                0x00000800                        
00692 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN2                0x00000400
00693 #define CMT_OUTPUTSETTINGS_POSITIONMODE_LLA_WGS84        0x00000000
00694 #define CMT_OUTPUTSETTINGS_VELOCITYMODE_MS_XYZ                0x00000000
00695 #define CMT_OUTPUTSETTINGS_TIMESTAMP_MASK                        0x00000003
00696 #define CMT_OUTPUTSETTINGS_ORIENTMODE_MASK                        0x0000000C
00697 #define CMT_OUTPUTSETTINGS_CALIBMODE_ACC_MASK                0x00000010
00698 #define CMT_OUTPUTSETTINGS_CALIBMODE_GYR_MASK                0x00000020
00699 #define CMT_OUTPUTSETTINGS_CALIBMODE_MAG_MASK                0x00000040
00700 #define CMT_OUTPUTSETTINGS_CALIBMODE_MASK                        0x00000070
00701 #define CMT_OUTPUTSETTINGS_DATAFORMAT_MASK                        0x00000300
00702 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN1_MASK        0x00000400
00703 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_AIN2_MASK        0x00000800
00704 #define CMT_OUTPUTSETTINGS_AUXILIARYMODE_MASK                0x00000C00
00705 #define CMT_OUTPUTSETTINGS_POSITIONMODE_MASK                0x0001C000
00706 #define CMT_OUTPUTSETTINGS_VELOCITYMODE_MASK                0x00060000
00707 #define CMT_OUTPUTSETTINGS_COORDINATES_NED                        0x80000000
00708 
00709 // Extended (analog) Output Modes
00710 #define CMT_EXTOUTPUTMODE_DISABLED                        0x0000
00711 #define CMT_EXTOUTPUTMODE_EULER                                0x0001
00712 
00713 // Initial tracking mode (SetInitTrackMode)
00714 #define CMT_INITTRACKMODE_DISABLED                0x0000
00715 #define CMT_INITTRACKMODE_ENABLED                0x0001
00716 
00717 // Filter settings params
00718 #define CMT_PARAM_FILTER_GAIN                        0x00
00719 #define CMT_PARAM_FILTER_RHO                        0x01
00720 #define CMT_DONOTSTORE                                        0x00
00721 #define CMT_STORE                                                0x01
00722 
00723 // AMDSetting (SetAMD)
00724 #define CMT_AMDSETTING_DISABLED                        0x0000
00725 #define CMT_AMDSETTING_ENABLED                        0x0001
00726 
00727 // Processing flags
00728 #define CMT_PROCESSINGFLAGS_IGBU_ENABLED        0x0001
00729 #define CMT_PROCESSINGFLAGS_FIXED_GRAVITY        0x0002
00730 
00731 // Send raw string mode
00732 #define CMT_SENDRAWSTRING_INIT                        0
00733 #define CMT_SENDRAWSTRING_DEFAULT                1
00734 #define CMT_SENDRAWSTRING_SEND                        2
00735 
00736 // Timeouts        
00737 #define CMT_TO_DEFAULT                                        500
00738 #define CMT_TO_INIT                                                250
00739 #define CMT_TO_RETRY                                        50
00740 
00741 #define        CMT_PERIOD_10HZ                                11520                // invalid with gps pulse time correction
00742 #define        CMT_PERIOD_12HZ                                9600
00743 #define        CMT_PERIOD_15HZ                                7680                // invalid with gps pulse time correction
00744 #define        CMT_PERIOD_16HZ                                7200
00745 #define        CMT_PERIOD_18HZ                                6400                // invalid with gps pulse time correction
00746 #define        CMT_PERIOD_20HZ                                5760
00747 #define        CMT_PERIOD_24HZ                                4800
00748 #define        CMT_PERIOD_25HZ                                4608                // invalid with gps pulse time correction
00749 #define        CMT_PERIOD_30HZ                                3840
00750 #define        CMT_PERIOD_32HZ                                3600
00751 #define        CMT_PERIOD_36HZ                                3200
00752 #define        CMT_PERIOD_40HZ                                2880
00753 #define        CMT_PERIOD_45HZ                                2560                // invalid with gps pulse time correction
00754 #define        CMT_PERIOD_48HZ                                2400
00755 #define        CMT_PERIOD_50HZ                                2304                // invalid with gps pulse time correction
00756 #define        CMT_PERIOD_60HZ                                1920
00757 #define        CMT_PERIOD_64HZ                                1800
00758 #define        CMT_PERIOD_72HZ                                1600
00759 #define        CMT_PERIOD_75HZ                                1536                // invalid with gps pulse time correction
00760 #define        CMT_PERIOD_80HZ                                1440
00761 #define        CMT_PERIOD_90HZ                                1280                // invalid with gps pulse time correction
00762 #define        CMT_PERIOD_96HZ                                1200
00763 
00764 #define        CMT_PERIOD_100HZ                        1152
00765 #define        CMT_PERIOD_120HZ                        960
00766 #define        CMT_PERIOD_128HZ                        900
00767 #define        CMT_PERIOD_144HZ                        800
00768 #define        CMT_PERIOD_150HZ                        768                        // invalid with gps pulse time correction
00769 #define        CMT_PERIOD_160HZ                        720
00770 #define        CMT_PERIOD_180HZ                        640
00771 #define        CMT_PERIOD_192HZ                        600
00772 #define        CMT_PERIOD_200HZ                        576
00773 #define        CMT_PERIOD_225HZ                        512                        // invalid with gps pulse time correction
00774 #define        CMT_PERIOD_240HZ                        480
00775 #define        CMT_PERIOD_256HZ                        450
00776 #define        CMT_PERIOD_288HZ                        400
00777 #define        CMT_PERIOD_300HZ                        384
00778 #define        CMT_PERIOD_320HZ                        360
00779 #define        CMT_PERIOD_360HZ                        320
00780 #define        CMT_PERIOD_384HZ                        300
00781 #define        CMT_PERIOD_400HZ                        288
00782 #define        CMT_PERIOD_450HZ                        256                        // invalid with gps pulse time correction
00783 #define        CMT_PERIOD_480HZ                        240
00784 #define        CMT_PERIOD_512HZ                        225
00785 
00786 // openPort baudrates
00787 #ifdef _WIN32
00788         #define CMT_BAUD_RATE_4800                                        CBR_4800
00789         #define CMT_BAUD_RATE_9600                                        CBR_9600
00790 //        #define CMT_BAUD_RATE_14K4                                        CBR_14400
00791         #define CMT_BAUD_RATE_19K2                                        CBR_19200
00792 //        #define CMT_BAUD_RATE_28K8                                        28800
00793         #define CMT_BAUD_RATE_38K4                                        CBR_38400
00794         #define CMT_BAUD_RATE_57K6                                        CBR_57600
00795         #define CMT_BAUD_RATE_115K2                                        CBR_115200
00796         #define CMT_BAUD_RATE_230K4                                        230400
00797         #define CMT_BAUD_RATE_460K8                                        460800
00798         #define CMT_BAUD_RATE_921K6                                        921600
00799 #else
00800         #define CMT_BAUD_RATE_4800                                        B4800
00801         #define CMT_BAUD_RATE_9600                                        B9600
00802 //        #define CMT_BAUD_RATE_14K4                                        B14400
00803         #define CMT_BAUD_RATE_19K2                                        B19200
00804 //        #define CMT_BAUD_RATE_28K8                                        B28800
00805         #define CMT_BAUD_RATE_38K4                                        B38400
00806         #define CMT_BAUD_RATE_57K6                                        B57600
00807         #define CMT_BAUD_RATE_115K2                                        B115200
00808         #define CMT_BAUD_RATE_230K4                                        B230400
00809         #define CMT_BAUD_RATE_460K8                                        B460800
00810         #define CMT_BAUD_RATE_921K6                                        B921600
00811 #endif
00812 
00813 #define CMT_DEFAULT_OUTPUT_MODE                        CMT_OUTPUTMODE_ORIENT
00814 #define CMT_DEFAULT_OUTPUT_SETTINGS                (CMT_OUTPUTSETTINGS_ORIENTMODE_QUATERNION |\
00815                                                                                  CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT)
00816 
00817 #define CMT_GOTO_CONFIG_TRIES                        3
00818 
00819 #define CMT_MAX_DEVICES_PER_PORT                11
00820 #define CMT_DEFAULT_SAMPLE_FREQUENCY        100
00821 #define CMT_DEFAULT_PERIOD                                1152
00822 #define CMT_DEFAULT_SKIP                                0
00823 #define CMT_DEFAULT_FILTER_GAIN                        1.0f
00824 #define CMT_DEFAULT_FILTER_WEIGHTING        1.0f
00825 #define CMT_SYNCOUT_DEFAULT_PULSE_WIDTH        1000000                // 1ms = 1M ns
00826 
00827 
00828 #define CMT_MAX_PORTS_PER_THREAD        20
00829 #define CMT_MAX_FILES_PER_THREAD        20
00830 #if CMT_MAX_PORTS_PER_THREAD >= CMT_MAX_FILES_PER_THREAD
00831 #        define CMT_MAX_DEVICES                        (CMT_MAX_PORTS_PER_THREAD * CMT_MAX_DEVICES_PER_PORT)
00832 #else
00833 #        define CMT_MAX_DEVICES                        (CMT_MAX_FILES_PER_THREAD * CMT_MAX_DEVICES_PER_PORT)
00834 #endif
00835 #define CMT_MAX_PACKETS_PER_BUNDLE        CMT_MAX_PORTS_PER_THREAD
00836 #define CMT_BUNDLE_QUEUE_SIZE                256
00837 #define CMT_MAX_ITEMS_IN_PACKET                10
00838 
00839         //! The default size of the serial read buffer in bytes
00840 #define CMT_DEFAULT_READ_BUFFER_SIZE                (CMT_MAXDATALEN*8)
00841         //! The default size of the serial write buffer in bytes
00842 #define CMT_DEFAULT_WRITE_BUFFER_SIZE                CMT_MAXDATALEN
00843         //! The default baud rate of the Cmt1s serial communication
00844 #define CMT_DEFAULT_BAUD_RATE                                CMT_BAUD_RATE_115K2
00845         //! The size of the L2 data-message fifo-queue
00846 #define CMT2_DATA_QUEUE_SIZE                                60
00847 
00848         //! The timeout value for "goto config"-message acknowledgement
00849 #define CMT3_CONFIG_TIMEOUT                                100
00850         //! The default timeout value for blocking CMT1s operations in ms
00851 #define CMT1_DEFAULT_TIMEOUT                        10
00852         //! Timeout in ms for level 2
00853 #define CMT2_DEFAULT_TIMEOUT                        50
00854         //! The default timeout value for L3 data reading
00855 #define CMT3_DEFAULT_TIMEOUT_MEAS                16
00856         //! The default timeout value for L3 configuration settings
00857 #define CMT3_DEFAULT_TIMEOUT_CONF                3000
00858         //! The default timeout value for L4 data reading at L2 and 3
00859 #define CMT4_DEFAULT_TIMEOUT_MEAS                1
00860         //! The default timeout value for L4 configuration settings
00861 #define CMT4_DEFAULT_TIMEOUT_CONF                CMT3_DEFAULT_TIMEOUT_CONF
00862         //! The timeout to use for requests during measurement mode
00863 #define CMT4_MEASUREMENT_REQ_TIMEOUT        100
00864         //! The standard timeout to use for data receipt in measurement mode
00865 #define CMT4_DEFAULT_TIMEOUT_DATA                3000
00866         //! The timeout used for reading a wakeup message in config mode
00867 #define CMT4_CONFIGWAIT_TIMEOUT                        50
00868 
00869 enum CmtControlLine {
00870         CMT_CONTROL_DCD                = 0x0001,                // pin 1: Carrier Detect
00871         CMT_CONTROL_RD                = 0x0002,                // pin 2: Received Data
00872         CMT_CONTROL_TD                = 0x0004,                // pin 3: Transmitted Data
00873         CMT_CONTROL_DTR                = 0x0008,                // pin 4: Data Terminal Ready
00874         CMT_CONTROL_GND                = 0x0010,                // pin 5: Common Ground
00875         CMT_CONTROL_DSR                = 0x0020,                // pin 6: Data Set Ready
00876         CMT_CONTROL_RTS                = 0x0040,                // pin 7: Request To Send
00877         CMT_CONTROL_CTS                = 0x0080,                // pin 8: Clear To Send
00878         CMT_CONTROL_RI                = 0x0100                // pin 9: Ring Indicator
00879 };
00880 
00881 // Reset orientation message type
00882 enum CmtResetMethod {
00883         CMT_RESETORIENTATION_STORE = 0,
00884         CMT_RESETORIENTATION_HEADING,
00885         CMT_RESETORIENTATION_GLOBAL,
00886         CMT_RESETORIENTATION_OBJECT,
00887         CMT_RESETORIENTATION_ALIGN
00888 };
00889 
00890 enum CmtXmSyncMode {
00891         CMT_XM_SYNC_OFF                                = 0x00,
00892         CMT_XM_SYNC_PWM                                = 0x01,
00893         CMT_XM_SYNC_MASTER                        = 0x10,
00894         CMT_XM_SYNC_SLAVE                        = 0x20,
00895         CMT_XM_SYNC_TOGGLE                        = 0x30
00896 };
00897 
00898 //! The type of a Device Id
00899 typedef uint32_t        CmtDeviceId;
00900 
00901 //! A structure for storing the firmware version
00902 struct CmtVersion {
00903         uint8_t m_major;
00904         uint8_t m_minor;
00905         uint8_t m_revision;
00906 };
00907 
00908 /* different alignment commands for gcc / MSVS, the structure needs to be 2-byte aligned
00909         because the deviceId field is 4 bytes long on offset 98.
00910 */
00911 #ifdef _MSC_VER
00912         #pragma pack(push, 2)
00913 #endif
00914 //! Structure containing a full device configuration as returned by the ReqConfig message.
00915 struct CmtDeviceConfiguration {
00916         uint32_t        m_masterDeviceId;
00917         uint16_t        m_samplingPeriod;
00918         uint16_t        m_outputSkipFactor;
00919         uint16_t        m_syncinMode;
00920         uint16_t        m_syncinSkipFactor;
00921         uint32_t        m_syncinOffset;
00922         uint8_t        m_date[8];
00923         uint8_t        m_time[8];
00924         uint8_t        m_reservedForHost[32];
00925         uint8_t        m_reservedForClient[32];
00926         uint16_t        m_numberOfDevices;
00927         struct _devInfo {
00928                 uint32_t        m_deviceId;
00929                 uint16_t        m_dataLength;
00930                 uint16_t        m_outputMode;
00931                 uint32_t        m_outputSettings;
00932                 uint16_t        m_currentScenario;
00933                 uint8_t                m_fwRevMajor;
00934                 uint8_t                m_fwRevMinor;
00935                 uint8_t                m_fwRevRevision;
00936                 uint8_t                m_filterType;
00937                 uint8_t                m_filterMajor;
00938                 uint8_t                m_filterMinor;
00939         } m_deviceInfo[CMT_MAX_DEVICES_PER_PORT];
00940 
00941 #ifndef _CMT_DLL_IMPORT
00942         void readFromMessage(const void* message);
00943 #endif
00944 }
00945 // different alignment commands for gcc / MSVS
00946 #ifdef _MSC_VER
00947         ;
00948         #pragma pack(pop)
00949 #else
00950         /*! \cond NODOXYGEN */        __attribute__((__packed__))        /*! \endcond */;
00951 #endif
00952 
00953 //////////////////////////////////////////////////////////////////////////////////////////
00954 
00955         //! An output mode bit-field
00956 typedef uint32_t CmtOutputMode;
00957         //! An output settings bit-field
00958 typedef uint64_t CmtOutputSettings;
00959 
00960         //! A structure for storing data formats
00961 struct CmtDataFormat {
00962         CmtOutputMode                m_outputMode;
00963         CmtOutputSettings        m_outputSettings;
00964 
00965 #ifndef _CMT_DLL_IMPORT
00966         //! default constructor, initializes to the given (default) MT settings
00967         CmtDataFormat(        const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
00968                                         const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS)
00969                                         : m_outputMode(mode), m_outputSettings(settings) {}
00970 #endif
00971 };
00972 
00973         //! An MT timestamp (sample count)
00974 typedef uint16_t CmtMtTimeStamp;
00975 
00976 #define CMT_MAX_FILENAME_LENGTH        512
00977 
00978 #define CMT_DID_BROADCAST                                0x80000000
00979 #define CMT_DID_MASTER                                        0
00980 
00981 
00982 //! A structure for storing sync in settings
00983 struct CmtSyncInSettings {
00984         uint16_t        m_mode;
00985         uint16_t        m_skipFactor;
00986         uint32_t        m_offset;                //!< Offset in ns
00987 
00988 #ifndef _CMT_DLL_IMPORT
00989         //! default constructor, initializes to the given (default) MT settings
00990         CmtSyncInSettings(        const uint16_t mode = 0,
00991                                                 const uint16_t skip = 0,
00992                                                 const uint32_t offset = 0)
00993                                                 : m_mode(mode), m_skipFactor(skip), m_offset(offset) {}
00994 #endif
00995 };
00996 
00997 //! A structure for storing sync out settings
00998 struct CmtSyncOutSettings {
00999         uint16_t        m_mode;
01000         uint16_t        m_skipFactor;
01001         uint32_t        m_offset;                //!< Offset in ns
01002         uint32_t        m_pulseWidth;        //!< Pulse width in ns
01003 
01004 #ifndef _CMT_DLL_IMPORT
01005         //! default constructor, initializes to the given (default) MT settings
01006         CmtSyncOutSettings( const uint16_t mode = 0,
01007                                                 const uint16_t skip = 0,
01008                                                 const uint32_t offset = 0,
01009                                                 const uint32_t width = CMT_SYNCOUT_DEFAULT_PULSE_WIDTH) :
01010                                                 m_mode(mode), m_skipFactor(skip), m_offset(offset),
01011                                                 m_pulseWidth(width) {}
01012 #endif
01013 };
01014 
01015 //! A structure for storing UTC Time values
01016 struct CmtUtcTime
01017 {
01018         uint32_t        m_nano;
01019         uint16_t        m_year;
01020         uint8_t        m_month;
01021         uint8_t        m_day;
01022         uint8_t        m_hour;
01023         uint8_t        m_minute;
01024         uint8_t        m_second;
01025         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 valid. when set to 0, the time is invalid and should be ignored.
01026 };
01027 
01028 //! A structure for storing device modes
01029 struct CmtDeviceMode {
01030         CmtOutputMode                m_outputMode;
01031         CmtOutputSettings        m_outputSettings;
01032         uint16_t                m_sampleFrequency;
01033 
01034 #ifndef _CMT_DLL_IMPORT
01035         //! default constructor, initializes to the given (default) MT settings
01036         CmtDeviceMode(        const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
01037                                         const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS,
01038                                         const uint16_t frequency = CMT_DEFAULT_SAMPLE_FREQUENCY) :
01039                                                 m_outputMode(mode), m_outputSettings(settings),
01040                                                 m_sampleFrequency(frequency) {}
01041         
01042         /*! \brief Compute the period and skip factor.
01043         
01044                 This function computes the period and skipFactor fields from the stored 
01045                 m_sampleFrequency field. The maximum error in the frequency is approximately 
01046                 0.4%, which occurs at 510Hz (= actually 512 Hz). In general, the higher 
01047                 frequencies are harder to set up exactly.
01048         */
01049         void getPeriodAndSkipFactor(uint16_t& period, uint16_t& skip) const;
01050         /*! \brief Return the real sample frequency in Hz. 
01051         
01052                 This may be up to 2Hz different from the value that is set.
01053         */
01054         double getRealSampleFrequency(void) const;
01055         /*! \brief Compute the sample frequency from a period and skip factor.
01056         
01057                 This function does the reverse of the getPeriodAndSkipFactor function, storing the
01058                 value in the m_sampleFrequency field.
01059         */
01060         void setPeriodAndSkipFactor(uint16_t period, uint16_t skip);
01061 
01062         //! Check if all fields of the two structures are equal
01063         bool operator == (const CmtDeviceMode& dev) const;
01064 #endif
01065 };
01066 
01067 //! A structure for storing device modes using period and skip factor (new default)
01068 struct CmtDeviceMode2 {
01069         CmtOutputMode                m_outputMode;
01070         CmtOutputSettings        m_outputSettings;
01071         uint16_t                m_period;
01072         uint16_t                m_skip;
01073 
01074 #ifndef _CMT_DLL_IMPORT
01075         //! default constructor, initializes to the given (default) MT settings
01076         CmtDeviceMode2(        const CmtOutputMode mode = CMT_DEFAULT_OUTPUT_MODE,
01077                 const CmtOutputSettings settings = CMT_DEFAULT_OUTPUT_SETTINGS,
01078                 const uint16_t period = CMT_DEFAULT_PERIOD,
01079                 const uint16_t skip = CMT_DEFAULT_SKIP) :
01080         m_outputMode(mode), m_outputSettings(settings),
01081                 m_period(period), m_skip(skip) {}
01082 
01083         /*! \brief Return the real sample frequency in Hz. 
01084 
01085         This may be up to 2Hz different from the value that is set.
01086         */
01087         double getRealSampleFrequency(void) const;
01088         /*! \brief Return the sample frequency in Hz. 
01089 
01090         This may be up to 2Hz different from the value that is set.
01091         */
01092         uint16_t getSampleFrequency(void) const;
01093         /*! \brief Compute the period and skip factor from a sample frequency.
01094 
01095         This function does the reverse of the getPeriodAndSkipFactor function, storing the
01096         value in the m_period and m_skip field.
01097         */
01098         void setSampleFrequency(uint16_t freq);
01099 
01100         //! Check if all fields of the two structures are equal
01101         bool operator == (const CmtDeviceMode2& dev) const;
01102 #endif
01103 };
01104 
01105 #define CMT_MAX_SCENARIOS_IN_MT                5
01106 #define CMT_MAX_SCENARIOS                        254
01107 
01108 //! A structure for storing scenario information
01109 struct CmtScenario {
01110         uint8_t m_type;                //!< The type of the scenario. When set to 255 in an operation, the 'current' scenario is used.
01111         uint8_t m_version;        //!< The version of the scenario.
01112         char m_label[CMT_LEN_SCENARIOLABEL+1];                //!< The label of the scenario.
01113         char m_filterType;                                                        //!< The type of the XKF filter this scenario is intended for '3': XKF-3, '6': XKF-6. \note The value is a character, so XKF-3 is '3', which is hex 0x33
01114         uint8_t m_filterMajor, m_filterMinor;                //!< The version of the XKF filter this scenario is intended for
01115 };
01116 
01117 enum CmtCallbackType {
01118         CMT_CALLBACK_LIST_TERMINATOR        = -1,//!< Not a callback function. Used to define the end of a CallbackSelector list
01119 
01120         CMT_CALLBACK_ONMEASUREMENTPREPARE,        //!< Called right before sending a GotoMeasurement message
01121         CMT_CALLBACK_ONMEASUREMENTSTART,        //!< Called right after successfully switching to Measurement mode
01122         CMT_CALLBACK_ONMEASUREMENTSTOP,                //!< Called right before switching from Measurement mode to Config mode
01123         CMT_CALLBACK_ONPOSTPROCESS,                        //!< Called when a full data bundle is available and has been processed by the CMT. The first void* parameter supplied to this function can be handed as the bundle parameter in cmtData... functions to manipulate the newly received bundle.
01124         CMT_CALLBACK_ONBYTESRECEIVED,                //!< Called when bytes have been read from a port
01125         CMT_CALLBACK_ONMESSAGERECEIVED,                //!< Called when a full message has been received from a port
01126         CMT_CALLBACK_ONMESSAGESENT,                        //!< Called when a full message has been sent by a port
01127         CMT_CALLBACK_ONMISSINGSAMPLES,                //!< Called when interpolation mode != 0 and missing samples are detected
01128         CMT_CALLBACK_ONWAKEUPRECEIVED,                //!< Called when receiving a wakeup message in config mode. Advise to refresh that port cache as soon as possible
01129         CMT_CALLBACK_ONINSTANCE,                        //!< 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.
01130 
01131         CMT_CALLBACK_COUNT                                        //!< Not a callback function. Used internally for list management
01132 };
01133 
01134 #define CmtCallbackSelector        CmtCallbackType
01135 
01136 enum CmtQueueMode {
01137         CMT_QM_FIFO        = 0,
01138         CMT_QM_LAST = 1,
01139         CMT_QM_RAW  = 2
01140 };
01141 
01142 struct CmtBinaryData {
01143         int32_t m_size;
01144         uint8_t m_data[CMT_MAXMSGLEN];
01145         uint16_t m_portNr;
01146 };
01147 
01148 typedef void (__cdecl * CmtCallbackFunction)(int32_t instance, int32_t callbackType, void* param, void* userParam);
01149 
01150 //! \brief Structure for storing information about a serial port
01151 struct CmtPortInfo {
01152         uint32_t m_baudrate;        //!< The baudrate at which an Xsens device was detected
01153         uint32_t m_deviceId;        //!< The device Id of the detected Xsens device
01154         uint16_t m_portNr;                //!< The port number
01155         char m_portName[256];                //!< The port name
01156 #ifdef __cplusplus
01157 #        ifdef _WIN32
01158                 //! greater than operator, used for sorting the list
01159         bool operator > (const CmtPortInfo& p) const { return m_portNr > p.m_portNr; }
01160                 //! less than operator, used for sorting the list
01161         bool operator < (const CmtPortInfo& p) const { return m_portNr < p.m_portNr; }
01162                 //! equality operator, used for finding items in a list
01163         bool operator == (const CmtPortInfo& p) const { return m_portNr == p.m_portNr; }
01164                 //! equality operator, used for finding items in a list
01165         bool operator == (const uint16_t port) const { return m_portNr == port; }
01166 #        else        // Linux
01167                 //! greater than operator, used for sorting the list
01168         bool operator > (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) > 0; }
01169                 //! less than operator, used for sorting the list
01170         bool operator < (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) < 0; }
01171                 //! equality operator, used for finding items in a list
01172         bool operator == (const CmtPortInfo& p) const { return strcmp(m_portName, p.m_portName) == 0; }
01173                 //! equality operator, used for finding items in a list
01174         bool operator == (const uint16_t port) const { (void)port; return false; }
01175 #        endif // ifdef _WIN32/Linux
01176 #endif
01177 };
01178 
01179 struct CmtShortVector {
01180         uint16_t m_data[3];
01181 };
01182 struct CmtRawData {
01183         CmtShortVector        m_acc,m_gyr,m_mag;
01184         uint16_t        m_temp;
01185 };
01186 struct CmtGpsPvtData {        uint16_t        m_pressure;
01187         uint8_t                m_pressureAge;
01188         uint32_t        m_itow;
01189         int32_t                m_latitude;
01190         int32_t                m_longitude;
01191         int32_t                m_height;
01192         int32_t                m_veln;
01193         int32_t                m_vele;
01194         int32_t                m_veld;
01195         uint32_t        m_hacc;
01196         uint32_t        m_vacc;
01197         uint32_t        m_sacc;
01198         uint8_t        m_gpsAge;
01199 };
01200 #define CmtRawGpsData        CmtGpsPvtData                //!< obsolete, use CmtGpsPvtData instead
01201 struct CmtRawPressureData {
01202         uint16_t        m_pressure;
01203         uint8_t                m_pressureAge;
01204 };
01205 struct CmtAnalogInData
01206 {
01207         uint16_t m_data;
01208 };
01209 struct CmtVector {
01210         double m_data[3];
01211 };
01212 struct CmtCalData {
01213         CmtVector        m_acc,m_gyr,m_mag;
01214 };
01215 struct CmtQuat {
01216         double m_data[4];
01217 };
01218 struct CmtEuler {
01219         double m_roll;                //!< The roll (rotation around x-axis / back-front-line)
01220         double m_pitch;                //!< The pitch (rotation around y-axis / right-left-line)
01221         double m_yaw;                //!< The yaw (rotation around z-axis / down-up-line)
01222 };
01223 struct CmtMatrix {
01224         double m_data[3][3];
01225 };
01226 
01227 #define CMT_MAX_SVINFO                16
01228 struct CmtGpsSatelliteInfo {
01229         uint8_t m_id;
01230         uint8_t m_navigationStatus;
01231         uint8_t m_signalQuality;
01232         uint8_t m_signalStrength;
01233 };
01234 struct CmtGpsStatus {
01235         CmtGpsSatelliteInfo m_svInfo[CMT_MAX_SVINFO];
01236 };
01237 
01238 typedef uint64_t CmtTimeStamp;
01239 
01240 #define CMT_AUTO_SAVE_FRAMES        5000
01241 #define CMT_FILE_LAST_FRAME                0xFFFFFFFF
01242 
01243 #define CMT_BID_BROADCAST                (const uint8_t)0x00
01244 #define CMT_BID_INVALID                        (const uint8_t)0xFE
01245 #define CMT_MID_REQEMTS                        (const uint8_t)0x90
01246 #define CMT_MID_EMTSDATA                (const uint8_t)0x91
01247 #define CMT_EMTS_SIZE                        1320
01248 
01249 #define CMT_STATUSFLAG_SELFTEST                                                0x01
01250 #define CMT_STATUSFLAG_XKFVALID                                                0x02
01251 #define CMT_STATUSFLAG_GPSVALID                                                0x04
01252 #define CMT_STATUSFLAG_NOROTATION_MASK                                0x18
01253 #define CMT_STATUSFLAG_NOROTATION                                         0x18
01254 #define CMT_STATUSFLAG_NOROTATION_ABORTED                         0x10
01255 #define CMT_STATUSFLAG_NOROTATION_SAMPLES_REJECTED         0x08
01256 
01257 #define CMT_MAX_VPORTNAME_LEN        32
01258 
01259 #endif
Generated on Sun May 8 08:05:57 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3