39 #define CMT3LOG CMTLOG 41 JanitorLogFunc<XsensResultValue, uint32_t> _cmtExitLog( \ 42 CMTLOG, "L3: " __FUNCTION__ " returns %u\n", m_lastResult); 49 #define CMT3LOGDAT CMTLOG 50 #define CMT3EXITLOGDAT \ 51 JanitorLogFunc<XsensResultValue, uint32_t> _cmtExitLog( \ 52 CMTLOG, "L3: " __FUNCTION__ " returns %u\n", m_lastResult); 54 #define CMT3LOGDAT(...) 55 #define CMT3EXITLOGDAT 58 #define CMT3F_DEVINFO_SIZE (sizeof(CmtDeviceId) + sizeof(CmtDataFormat)) 129 return (115200.0 / ((1.0 + (
double)skip) * (
double)period));
137 (115200.0 / ((1.0 + (
double)skip) * (
double)period)) + 0.5);
156 return (115200.0 / ((
double)
m_period));
178 if (frequency >= 512)
210 #define DO_DATA_REQUEST_BID(req, bid) \ 211 Message snd(req, 0); \ 213 if (bid == CMT_BID_INVALID || bid == CMT_BID_BROADCAST) \ 214 return (m_lastResult = XRV_INVALIDID); \ 215 if (!m_readFromFile) \ 218 m_serial.writeMessage(&snd); \ 219 if ((m_lastResult = \ 220 m_serial.waitForMessage(&rcv, req + 1, 0, true)) != XRV_OK) \ 221 return m_lastResult; \ 222 if (m_logging) m_logFile.writeMessage(&rcv); \ 223 if (rcv.getMessageId() == CMT_MID_ERROR) \ 225 m_lastHwErrorDeviceId = m_config.m_masterDeviceId; \ 226 if (rcv.getDataSize() >= 2) \ 228 uint8_t biddy = rcv.getDataByte(1); \ 229 getDeviceId(biddy, m_lastHwErrorDeviceId); \ 231 return m_lastResult = m_lastHwError = \ 232 (XsensResultValue)rcv.getDataByte(); \ 238 if ((m_lastResult = m_logFile.readMessage(&rcv, req + 1)) != \ 240 return m_lastResult; \ 241 if (rcv.getBusId() == bid || \ 242 (rcv.getBusId() == 1 && bid == CMT_BID_MASTER)) \ 246 #define DO_DATA_REQUEST(req) \ 247 uint8_t bid = getBusIdInternal(deviceId); \ 248 DO_DATA_REQUEST_BID(req, bid); 252 #define DO_DATA_SET_BID(req, size, type, data, bid) \ 253 Message snd(req, size); \ 255 snd.setData##type(data); \ 256 if (bid == CMT_BID_BROADCAST) \ 258 for (uint8_t i = 0; i < m_config.m_numberOfDevices; ++i) \ 260 snd.setBusId(i + 1); \ 261 m_serial.writeMessage(&snd); \ 262 m_lastResult = m_serial.waitForMessage(&rcv, req + 1, 0, true); \ 263 if (m_lastResult != XRV_OK) return m_lastResult; \ 264 if (m_logging) m_logFile.writeMessage(&rcv); \ 265 if (rcv.getMessageId() == CMT_MID_ERROR) \ 267 m_lastHwErrorDeviceId = m_config.m_masterDeviceId; \ 268 if (rcv.getDataSize() >= 2) \ 270 uint8_t biddy = rcv.getDataByte(1); \ 271 getDeviceId(biddy, m_lastHwErrorDeviceId); \ 273 return m_lastResult = m_lastHwError = \ 274 (XsensResultValue)rcv.getDataByte(); \ 281 m_serial.writeMessage(&snd); \ 282 m_lastResult = m_serial.waitForMessage(&rcv, req + 1, 0, true); \ 283 if (m_lastResult != XRV_OK) return m_lastResult; \ 284 if (m_logging) m_logFile.writeMessage(&rcv); \ 285 if (rcv.getMessageId() == CMT_MID_ERROR) \ 287 m_lastHwErrorDeviceId = m_config.m_masterDeviceId; \ 288 if (rcv.getDataSize() >= 2) \ 290 uint8_t biddy = rcv.getDataByte(1); \ 291 getDeviceId(biddy, m_lastHwErrorDeviceId); \ 293 return m_lastResult = m_lastHwError = \ 294 (XsensResultValue)rcv.getDataByte(); \ 298 #define DO_DATA_SET(req, size, type, data) \ 299 uint8_t bid = getBusIdInternal(deviceId); \ 300 if (bid == CMT_BID_INVALID) return (m_lastResult = XRV_INVALIDID); \ 301 DO_DATA_SET_BID(req, size, type, data, bid); 303 #define HANDLE_ERR_RESULT \ 304 if (rcv.getMessageId() == CMT_MID_ERROR) \ 306 m_lastHwErrorDeviceId = m_config.m_masterDeviceId; \ 307 if (rcv.getDataSize() >= 2) \ 309 uint8_t biddy = rcv.getDataByte(1); \ 310 getDeviceId(biddy, m_lastHwErrorDeviceId); \ 312 return m_lastResult = m_lastHwError = \ 313 (XsensResultValue)rcv.getDataByte(0); \ 365 CMT3LOG(
"L3: Closing L2 port\n");
413 state = (rcv.getDataShort() != 0);
422 CMT3LOG(
"L3: getBatteryLevel\n");
426 level = rcv.getDataByte();
446 CMT3LOG(
"L3: getBluetoothState\n");
451 (rcv.getDataByte() == 0);
499 CMT3LOG(
"L3: getBusPowerState\n");
504 (rcv.getDataShort() !=
517 CMT3LOG(
"L3: getConfiguration\n");
576 length = rcv.getDataShort();
584 CMT3LOG(
"L3: getDeviceCount\n");
716 for (
uint8_t page=0;page < 4;++page)
719 for (
uint8_t part=0;part < 4;++part, ++emtPos)
827 mode = rcv.getDataShort();
832 mode = rcv.getDataShort();
933 CMT3LOG(
"L3: getLogFileReadPosition\n");
949 CMT3LOG(
"L3: getLogFileSize\n");
966 CMT3LOG(
"L3: getLogFileName (char)\n");
979 CMT3LOG(
"L3: getLogFileName (wchar_t)\n");
1059 productCode[
len] =
'\0';
1068 CMT3LOG(
"L3: getSampleFrequency\n");
1073 return mode.getSampleFrequency();
1080 CMT3LOG(
"L3: getSerialBaudrate\n");
1129 CMT3LOG(
"L3: getSyncInSettings\n");
1175 CMT3LOG(
"L3: getSyncInMode\n");
1199 CMT3LOG(
"L3: getSyncInSkipFactor\n");
1223 CMT3LOG(
"L3: getSyncInOffset\n");
1262 CMT3LOG(
"L3: getSyncOutSettings\n");
1319 CMT3LOG(
"L3: getSyncOutMode\n");
1343 CMT3LOG(
"L3: getSyncOutPulseWidth\n");
1371 CMT3LOG(
"L3: getSyncOutSkipFactor\n");
1395 CMT3LOG(
"L3: getSyncOutOffset\n");
1450 CMT3LOG(
"L3: getXmOutputMode\n");
1478 CMT3LOG(
"L3: Attempt to goto config %d\n", tries);
1497 "L3: Goto config failed, error received %d: %s\n",
1502 CMT3LOG(
"L3: Goto config succeeded\n");
1508 msleep(((
long)rand() * 10) / RAND_MAX);
1523 "L3: gotoMeasurement port %u\n",
1569 "L3: openPort Opening port %s @baud %d, timeoutC=%u, timeoutM=%u\n",
1579 CMT3LOG(
"L3: openPort: Low level port opened, gotoConfig\n");
1590 "L3: openPort: gotoConfig failed: [%d]%s\n",
m_lastResult,
1596 CMT3LOG(
"L3: openPort: gotoConfig succeeded, requesting initBus\n");
1602 "L3: openPort: initBus failed: [%d]%s\n",
m_lastResult,
1608 CMT3LOG(
"L3: openPort: initBus succeeded, cleaning up the cache\n");
1613 "L3: openPort: refreshCache failed: [%d]%s\n",
m_lastResult,
1618 CMT3LOG(
"L3: openPort: returning OK\n");
1630 "L3: openPort Opening port %d @baud %d, timeoutC=%u, timeoutM=%u\n",
1640 CMT3LOG(
"L3: openPort: Low level port opened, gotoConfig\n");
1651 "L3: openPort: gotoConfig failed: [%d]%s\n",
m_lastResult,
1657 CMT3LOG(
"L3: openPort: gotoConfig succeeded, requesting initBus\n");
1663 "L3: openPort: initBus failed: [%d]%s\n",
m_lastResult,
1669 CMT3LOG(
"L3: openPort: initBus succeeded, cleaning up the cache\n");
1674 "L3: openPort: refreshCache failed: [%d]%s\n",
m_lastResult,
1679 CMT3LOG(
"L3: openPort: returning OK\n");
1688 CMT3LOG(
"L3: peekLogMessageId started\n");
1701 CMT3LOG(
"L3: peekLogMessageId, no messages to be read\n");
1706 "L3: peekLogMessageId found msg with ID %02x\n", (
int32_t)messageId);
1714 CMT3LOGDAT(
"L3: readDataPacket %p %u\n", pack, acceptOther ? 1 : 0);
1724 CMT3LOGDAT(
"L3: readDataPacket, no data messages to be read\n");
1741 CMT3LOGDAT(
"L3: readDataPacket, data message read\n");
1756 "L3: readDataPacket, non-data message read: %2x\n",
1772 CMT3LOGDAT(
"L3: readDataPacket, no data messages to be read\n");
1788 CMT3LOGDAT(
"L3: readDataPacket, data message read\n");
1803 "L3: readDataPacket, non-data message read: %2x\n",
1890 CMT3LOG(
"L3: setBaudrate %u %u\n", baudrate, reconnect ? 1 : 0);
1940 CMT3LOG(
"L3: sending reset for reconnect\n");
1953 CMT3LOG(
"L3: reopening port at new baud rate\n");
1978 CMT3LOG(
"L3: setBluetoothState %u\n", enabled ? 1 : 0);
1981 uint8_t dat = (enabled ? 0 : 1);
1991 CMT3LOG(
"L3: setBusPowerState %u\n", enabled ? 1 : 0);
2005 "L3: setDeviceMode %04x %08x %u %u %08x\n", (
uint32_t)
mode.m_outputMode,
2024 "L3: setDeviceMode2 %04x %08x %u %u %u %08x\n",
2063 xperiod =
mode.m_period * (
mode.m_skip + 1);
2065 xperiod =
mode.m_period;
2070 "L3: setDeviceMode setting device %08x period to %u\n",
2087 "L3: setDeviceMode setting MT %08x skip factor to %u\n",
2117 "L3: setDeviceMode setting MT %08x output mode to %04X\n",
2140 "L3: setDeviceMode setting MT %08x output settings to %08X\n",
2218 CMT3LOG(
"L3: setMagneticDeclination %f %08x\n", declination,
deviceId);
2223 (
float)declination);
2231 CMT3LOG(
"L3: setXmPowerOff\n");
2321 CMT3LOG(
"L3: setSyncInSettings %u\n", skipFactor);
2391 "L3: setSyncOutSettings %u %u %u %u\n", (
uint32_t)settings.
m_mode,
2478 CMT3LOG(
"L3: setSyncOutSettings %u\n", pulseWidth);
2505 CMT3LOG(
"L3: setSyncOutSettings %u\n", skipFactor);
2558 CMT3LOG(
"L3: setTimeoutConfig %u\n", timeout);
2570 CMT3LOG(
"L3: setTimeoutMeasurement %u\n", timeout);
2595 CMT3LOG(
"L3: refreshCache %d\n", file ? 1 : 0);
2612 "L3: refreshCache Device in configuration mode, reading device " 2647 "L3: refreshCache Reading device configuration information from " 2675 CMT3LOGDAT(
"L3: waitForDataMessage %p\n", pack);
2719 "L3: createLogFile \"%s\" %u\n", filename ? filename :
"",
2720 startLogging ? 1 : 0);
2752 "L3: createLogFile \"%S\" %u\n", filename ? filename : L
"",
2753 startLogging ? 1 : 0);
2784 CMT3LOG(
"L3: closeLogFile %u\n", del ? 1 : 0);
2798 CMT3LOG(
"L3: isLogFileOpen \"%s\"\n", filename ? filename :
"");
2802 if (filename !=
nullptr && filename[0] != 0)
2817 CMT3LOG(
"L3: isLogFileOpen \"%S\"\n", filename ? filename : L
"");
2821 if (filename !=
nullptr && filename[0] != L
'\0')
2836 CMT3LOG(
"L3: openLogFile \"%s\"\n", filename ? filename :
"");
2859 CMT3LOG(
"L3: openLogFile \"%S\"\n", filename ? filename : L
"");
2882 CMT3LOG(
"L3: setDataSource %s\n", readFromFile ?
"file" :
"port");
2913 CMT3LOG(
"L3: setLogMode %u\n", active ? 1 : 0);
2925 CMT3LOG(
"L3: resetLogFileReadPos\n");
2934 CMT3LOG(
"L3: writeMessageToLogFile\n");
2969 scenarios[i].m_label,
2996 auto scenario = (
uint16_t)scenarioType;
3058 "L3: setGpsLeverArm [%f %f %f] %08x\n", arm.
m_data[0], arm.
m_data[1],
#define CMT_MID_REQAVAILABLESCENARIOS
void fillRtc(Packet *pack)
Internal function to compute the RTC value.
#define CMT_MID_REQBTDISABLE
XsensResultValue initBus(void)
Perform an initBus request.
void readFromMessage(const void *message)
#define CMT_MID_REQGPSLEVERARM
uint32_t getDataLong(const uint16_t offset=0) const
Return the current value of the data as an uint32_t (32 bits).
A structure for storing the firmware version.
Operation was performed successfully.
char m_filterType
The type of filter this scenario is intended for '3': XKF-3, '6': XKF-6.
CmtDeviceId getMasterId(void)
XsensResultValue getSyncOutSkipFactor(uint16_t &skipFactor)
Retrieve the outbound synchronization skip factor of an MT device.
XsensResultValue getSyncMode(uint8_t &mode)
Retrieve the sync mode of the Xbus Master.
XsensResultValue getMagneticDeclination(double &declination, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the stored magnetic declination.
#define CMT_GOTO_CONFIG_TRIES
#define CMT_MID_REQSYNCOUTSETTINGSACK
XsensResultValue getPortNr(uint8_t &port) const
Return the device Id of an MT device.
#define DO_DATA_REQUEST_BID(req, bid)
double m_rtcMsPerSample
ms per sample = 1000 / sample frequency.
uint8_t m_type
The type of the scenario.
XsensResultValue setSyncOutSkipFactor(const uint16_t skipFactor)
Set the outbound synchronization skip factor of an MT device.
#define CMT_PARAM_SYNCOUT_SKIPFACTOR
uint16_t m_skip
The skip factor of the port.
TimeStamp m_toa
Time of arrival.
TimeStamp m_rtcStart
The start of the RTC counter, the time of arrival of sample 0.
unsigned __int16 uint16_t
Mid-level serial communication class.
XsensResultValue setBusPowerState(const bool enabled)
Switch the Xbus Master bus power on or off.
uint32_t getDeviceCount(void) const
Retrieve total device count.
XsensResultValue getGpsLeverArm(CmtVector &arm, const CmtDeviceId deviceId=CMT_DID_MASTER)
Get the currently used GPS lever arm.
XsensResultValue openPort(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
XsensResultValue setSyncOutPulseWidth(const uint32_t pulseWidth)
Set the outbound synchronization pulse width of an MT device.
#define CMT_MID_CONFIGURATION
XsensResultValue open(const char *filename, const bool readOnly=false)
Open a file and read the header.
#define CMT_MID_SETGPSLEVERARM
#define CMT_MID_REQBATLEVEL
XsensResultValue getGpsStatus(CmtGpsStatus &status, const CmtDeviceId deviceId=CMT_DID_MASTER)
Request the status of the GPS satellites in orbit.
uint8_t m_version
The version of the scenario.
bool m_readFromFile
Indicates whether to read from the log file or from the serial port.
#define XSENS_MS_PER_DAY
The number of milliseconds in a normal day.
#define CMT_MID_REQOUTPUTMODE
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...
#define CMT_MID_REQPERIODACK
XsensResultValue refreshCache(const bool file=false)
Update device information stored on host PC.
void resizeData(const uint16_t newSize)
Resize the data area to the given size.
#define CMT_MID_GOTOMEASUREMENT
#define CMT_LEN_RESETORIENTATION
XsensResultValue getSyncOutPulseWidth(uint32_t &pulseWidth)
Retrieve the outbound synchronization pulse width of an MT device.
XsensResultValue getBatteryLevel(uint8_t &level)
Get an Xbus Master's battery level.
#define CMT_MID_REQSYNCOUTSETTINGS
Cmt2f * getCmt2f(void)
Return a reference to the embedded Cmt2f (logfile) object.
#define CMT_BAUD_RATE_230K4
XsensResultValue getLogFileReadPosition(CmtFilePos &pos)
Retrieve the read position of the log file.
XsensResultValue getDeviceId(const uint8_t busId, CmtDeviceId &deviceId) const
Retrieve the DeviceId of a device given its Bus ID.
#define CMT_MID_REQOUTPUTSKIPFACTORACK
XsensResultValue getPortNr(uint8_t &port) const
Retrieve the port that the object is connected to.
#define CMT_MAX_FILENAME_LENGTH
uint32_t m_offset
Offset in ns.
XsensResultValue setDeviceMode(const CmtDeviceMode &mode, bool force, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the complete output mode of a device.
XsensResultValue readDataPacket(Packet *pack, bool acceptOther=false)
Retrieve a data message.
bool m_logging
Indicates whether to write all received messages to the logfile or not, automatically set to true by ...
A structure for storing sync out settings.
XsensResultValue getDeviceMode(CmtDeviceMode &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return device mode.
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
#define CMT_BAUD_RATE_9600
uint8_t m_reservedForClient[32]
uint32_t m_rtcCount
The long sample counter (normal counter wraps at 64k).
XsensResultValue restoreFactoryDefaults(const CmtDeviceId deviceId=CMT_DID_MASTER)
Restore the device to factory default settings.
#define CMT_MID_REQSYNCMODE
XsensResultValue resetLogFileReadPos(void)
Restart reading from the start of the open log file.
XsensResultValue getLastResult(void) const
Return the error code of the last operation.
XsensResultValue setSyncInMode(const uint16_t mode)
Set the inbound synchronization mode of an MT device.
XsensResultValue getLocationId(uint16_t &locationId, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the location ID of a sensor.
#define CMT_DID_TYPEH_MASK
bool m_rtcInitialized
Indicates if the rtc is initialised or not.
bool isLogFileOpen(const char *filename) const
Return whether or not(true or false) the supplied file is open.
uint16_t m_gotoConfigTries
The number of times a goto config is attempted before the function fails.
#define DO_DATA_SET(req, size, type, data)
#define CMT_DID_TYPEH_MTI_MTX
#define CMT_MID_STOREXKFSTATE
XsensResultValue gotoMeasurement(void)
Place all connected devices into Measurement Mode.
double getRealSampleFrequency(void) const
Return the real sample frequency in Hz.
uint16_t getDataSize(void) const
Return the length of the data part of the message.
A structure for storing UTC Time values.
XsensResultValue reset(void)
Request a data.
uint16_t m_itemCount
The number of data items in the message.
XsensResultValue getSyncInOffset(uint32_t &offset)
Retrieve the inbound synchronization offset of an MT device.
#define CMT_MID_REQUTCTIME
XsensResultValue getMtDeviceId(const uint8_t index, CmtDeviceId &deviceId) const
#define CMT_DID_BROADCAST
A structure for storing sync in settings.
uint16_t getSampleCounter(const uint16_t index=0) const
Return the Sample Counter component of the packet.
#define CMT_MID_REQGPSSTATUS
uint32_t m_pulseWidth
Pulse width in ns.
XsensResultValue getSyncInSettings(CmtSyncInSettings &settings)
Retrieve the inbound synchronization settings of the master MT device.
TimeStamp timeStampNow(void)
#define CMT_MID_REQSYNCINSETTINGSACK
uint32_t m_offset
Offset in ns.
XsensResultValue writeMessageToLogFile(const Message &msg)
XsensResultValue setErrorMode(const uint16_t mode)
Set the error mode of the device.
uint16_t getMtCount(void) const
Return the device Id of the first.
XsensResultValue getName(char *filename) const
Retrieve the filename that was last successfully opened.
#define CMT_MID_SETGPSLEVERARMACK
#define CMT_MID_REQBAUDRATE
XsensResultValue setXmPowerOff(void)
Switch the connected Xbus Master.
uint16_t getDataShort(const uint16_t offset=0) const
Return the current value of the data as an uint16_t (16 bits).
#define CMT_BAUD_RATE_57K6
XsensResultValue setDeviceMode2(const CmtDeviceMode2 &mode, bool force, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the complete output mode2 of a device.
void getPeriodAndSkipFactor(uint16_t &period, uint16_t &skip) const
Compute the period and skip factor.
#define CMT_MID_GOTOMEASUREMENTACK
XsensResultValue getConfiguration(CmtDeviceConfiguration &configuration)
Get device configuration.
void recomputeChecksum(void)
Compute the checksum field and fill it.
XsensResultValue getSyncOutSettings(CmtSyncOutSettings &settings)
Retrieve the outbound synchronization settings of the master MT device.
#define HANDLE_ERR_RESULT
XsensResultValue getHeading(double &heading, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the heading offset.
XsensResultValue getPortName(char *portname) const
bool isXm(void) const
Return whether the main device is an Xbus Master or not.
A structure containing MT data + timestamp and formatting information.
XsensResultValue closeLogFile(bool del=false)
Close an open log file.
void clearHwError(void)
Reset the hardware error code.
bool operator==(const CmtDeviceMode &dev) const
Check if all fields of the two structures are equal.
Cmt2s * getCmt2s(void)
Return a reference to the embedded Cmt2s (comm port) object.
XsensResultValue setBaudrate(const uint32_t baudrate, bool reconnect=true)
Set the baudrate and possibly reconnect.
XsensResultValue getAvailableScenarios(CmtScenario *scenarios, const CmtDeviceId deviceId=CMT_DID_MASTER)
Write the specified message to the open.
XsensResultValue getBusId(uint8_t &busId, const CmtDeviceId deviceId=CMT_DID_MASTER) const
Retrieve the BusId of a device.
Cmt3()
Default constructor, initializes all members to their default values.
XsensResultValue setDataSource(bool readFromFile)
Set whether to read from comm port or file.
XsensResultValue setSyncOutSettings(const CmtSyncOutSettings &settings)
Set the outbound synchronization settings of an MT device.
XsensResultValue setMagneticDeclination(const double declination, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the stored magnetic declination.
#define CMT_MID_REQMAGNETICDECLINATION
uint8_t getBusIdInternal(const CmtDeviceId devId) const
Find a device Id in the list and return its busId.
TimeStamp m_rtc
Sample time in ms, based on the sample counter.
Structure containing a full device configuration as returned by the ReqConfig message.
XsensResultValue setGpsLeverArm(const CmtVector &arm, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the currently used GPS lever arm.
XsensResultValue setXmOutputMode(const uint8_t mode)
Set the dual-output mode of the XM.
XsensResultValue requestData(Packet *pack)
#define CMT_MID_REQXMERRORMODE
The mid-level file communication class.
#define CMT_DEFAULT_PERIOD
CmtOutputMode m_outputMode
void msleep(uint32_t ms)
A platform-independent sleep routine.
float getDataFloat(const uint16_t offset=0) const
Return the current value of the data as a float (32 bits).
uint32_t m_baudrate
The baudrate that was last set to be used by the port.
#define CMT_MID_REQERRORMODE
#define CMT_LEN_STOREXKFSTATE
uint16_t m_samplingPeriod
XsensResultValue getLogFileName(char *filename)
Retrieve the name of the open log file or an empty string if no logfile is open.
XsensResultValue openLogFile(const char *filename)
Open a log file for input.
bool operator==(const CmtDeviceMode2 &dev) const
Check if all fields of the two structures are equal.
XsensResultValue close(void)
Close the file.
#define DO_DATA_SET_BID(req, size, type, data, bid)
#define CMT_DID_TYPEH_MTIG
Cmt1s * getCmt1s(void)
Return a reference to the embedded Cmt1s object.
#define CMT_MID_REQPRODUCTCODE
#define CMT_LEN_ERRORMODE
#define CMT_LEN_GRAVITYMAGNITUDE
XsensResultValue getErrorMode(uint16_t &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the error mode of the device.
XsensResultValue setGravityMagnitude(const double magnitude, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the currently used magnitude of the gravity vector.
#define CMT_MID_REQOUTPUTMODEACK
struct CmtDeviceConfiguration::_devInfo m_deviceInfo[CMT_MAX_DEVICES_PER_PORT]
uint16_t m_numberOfDevices
XsensResultValue getScenario(uint8_t &scenarioType, uint8_t &scenarioVersion, const CmtDeviceId deviceId=CMT_DID_MASTER)
Get the currently active scenario from a Motion Tracker.
XsensResultValue
Xsens return values.
#define CMT_OUTPUTSETTINGS_TIMESTAMP_MASK
#define CMT_BAUDCODE_115K2
#define CMT_MID_REQFILTERSETTINGSACK
XsensResultValue createLogFile(const char *filename, bool startLogging=false)
Create a log file for incoming messages.
CmtDeviceId m_lastHwErrorDeviceId
Contains the Device ID of the device that caused the last hardware error.
#define CMT_MID_REQHEADING
#define CMT_MAX_SCENARIOS_IN_MT
#define CMT_MID_REQSYNCINSETTINGS
XsensResultValue closeAndDelete(void)
Close the file and delete it.
uint32_t m_timeoutMeas
The measurement mode timeout.
CmtFilePos getReadPosition(void)
Get the current read position.
Cmt2s m_serial
The (optional) CMT level 2 serial object that this class operates on.
XsensResultValue getUtcTime(CmtUtcTime &utc, const CmtDeviceId deviceId)
Return the UTC time of the last received sample.
void setSampleFrequency(uint16_t freq)
Compute the period and skip factor from a sample frequency.
XsensResultValue getSyncInMode(uint16_t &mode)
Retrieve the inbound synchronization mode of an MT device.
double getRealSampleFrequency(void) const
Return the real sample frequency in Hz.
uint32_t m_outputSettings
#define CMT_PARAM_SYNCOUT_OFFSET
#define CMT_MID_REQSCENARIO
uint64_t TimeStamp
A real-time timestamp (ms)
#define CMT_MID_REQCONFIGURATION
XsensResultValue open(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
Open a communication channel to the given serial port name.
#define CMT_BAUD_RATE_38K4
#define CMT_MID_RESTOREFACTORYDEF
#define CMT_BAUD_RATE_460K8
XsensResultValue waitForMessage(Message *rcv, const uint8_t msgId, uint32_t timeoutOverride, bool acceptErrorMessage)
Wait for a message to arrive.
#define CMT_MID_SETMAGNETICDECLINATION
void setDataFloat(const float data, const uint16_t offset=0)
Write a float (32 bits) into the data buffer.
#define CMT_MID_SETGRAVITYMAGNITUDE
#define CMT_BAUDCODE_230K4
XsensResultValue setSyncOutOffset(const uint32_t offset)
Set the outbound synchronization offset of an MT device.
#define CMT_LEN_SCENARIOLABEL
XsensResultValue getSerialBaudrate(uint32_t &baudrate)
Return the baud rate used for serial communication.
#define CMT_MID_REQOUTPUTSKIPFACTOR
#define CMT_BAUDCODE_57K6
XsensResultValue storeXkfState(const CmtDeviceId deviceId=CMT_DID_MASTER)
Store important components of the XKF filter state to non-volatile memory.
uint32_t getTimeoutConfig(void) const
Return the configuration mode timeout.
#define CMT_LEN_LOCATIONID
~Cmt3()
Destructor, de-initializes, frees memory allocated for buffers, etc.
void setDataLong(const uint32_t data, const uint16_t offset=0)
Write an uint32_t (32 bits) into the data buffer.
#define CMT_BID_BROADCAST
XsensResultValue getProductCode(char *productCode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return product code.
XsensResultValue getDataLength(uint32_t &length, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve data size.
#define CMT_PARAM_SYNCIN_OFFSET
#define CMT_CONF_BLOCKLEN
#define CMT_LEN_BTDISABLE
XsensResultValue setTimeoutMeasurement(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_MEAS)
Set the measurement mode timeout.
#define CMT_PARAM_SYNCIN_SKIPFACTOR
CmtOutputSettings m_outputSettings
#define CMT_PARAM_SYNCIN_MODE
CmtFilePos getFileSize(void)
Get the current file size.
uint32_t m_timeoutConf
The config mode timeout.
XsensResultValue setReadPosition(CmtFilePos pos)
Set the read position to the given position.
uint8_t * getDataBuffer(const uint16_t offset=0)
Return a pointer to the data buffer.
char m_label[CMT_LEN_SCENARIOLABEL+1]
The label of the scenario.
XsensResultValue getSyncOutMode(uint16_t &mode)
Retrieve the outbound synchronization mode of an MT device.
#define CMT_LEN_SETSCENARIO
A structure for storing device modes using period and skip factor (new default)
uint16_t m_sampleFrequency
#define CMT_BAUDCODE_460K8
#define CMT3_DEFAULT_TIMEOUT_MEAS
The default timeout value for L3 data reading.
uint8_t getMessageId(void) const
Return the current value of the m_messageId field.
void setPeriodAndSkipFactor(uint16_t period, uint16_t skip)
Compute the sample frequency from a period and skip factor.
XsensResultValue getEMtsData(void *buffer, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve the eMts data of the specified sensor(s).
XsensResultValue setLocationId(uint16_t locationId, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the location ID of a sensor.
bool m_measuring
Keeps track of whether the connected device is measuring or being configured.
XsensResultValue close(void)
Close the serial communication port.
XsensResultValue setTimeoutConfig(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_CONF)
Set the configuration mode timeout.
const uint8_t * getMessageStart(void) const
Return the start of the message buffer.
bool setDataFormat(const CmtDataFormat &format, const uint16_t index=0)
XsensResultValue setSyncInSettings(const CmtSyncInSettings &settings)
Set the inbound synchronization settings of an MT device.
uint8_t getPortNr(void) const
Retrieve the port number that was last successfully opened.
#define CMT_MID_GOTOCONFIGACK
#define CMT_BAUDCODE_38K4
CmtMtTimeStamp m_rtcLastSc
The last received sample counter, used to determine wrap-around.
XsensResultValue setTimeout(const uint32_t ms=CMT2_DEFAULT_TIMEOUT)
Set the default timeout value to use in blocking operations.
XsensResultValue m_lastResult
The last result of an operation.
bool isOpen(void) const
Return whether the communication port is open or not.
#define DO_DATA_REQUEST(req)
bool m_useRtc
Indicates if the RTC should be computed or not (to save CPU time).
#define CMT3_CONFIG_TIMEOUT
The timeout value for "goto config"-message acknowledgement.
#define CMT_MID_REQGRAVITYMAGNITUDE
XsensResultValue writeMessage(Message *msg)
Send a message over the COM port.
XsensResultValue m_lastHwError
Contains the last error reported by hardware.
XsensResultValue create(const char *filename)
Create a new file with level 2 header.
XsensResultValue setSyncInSkipFactor(const uint16_t skipFactor)
Set the inbound synchronization skip factor of an MT device.
GLuint GLsizei GLsizei * length
#define CMT_MID_REQDATALENGTH
#define CMT_BAUD_RATE_115K2
XsensResultValue setSyncMode(const uint8_t mode)
Set the sync mode of the Xbus Master.
uint32_t getTimeoutMeasurement(void) const
Return the measurement mode timeout.
uint16_t getSampleFrequency(void)
Return current sample frequency.
#define CMT_MID_REQLOCATIONID
XsensResultValue setBluetoothState(const bool enabled)
Set the Bluetooth state of the Xbus Master.
#define CMT_MID_STOREXKFSTATEACK
#define CMT_LEN_MAGNETICDECLINATION
const char * xsensResultText(const XsensResultValue result)
#define CMT_BAUDCODE_921K6
uint8_t getDataByte(const uint16_t offset=0) const
Return the current value of the data as an unsigned byte (8 bits).
XsensResultValue waitForDataMessage(Packet *pack)
Wait for a data message to arrive.
XsensResultValue readMessage(Message *msg, const uint8_t msgId=0)
Read the next message from the file, when msgId is non-zero, the first matching message will be retur...
bool isOpen(void) const
Return whether the file is open or not.
#define CMT_LEN_GPSLEVERARM
void setXbus(bool xbus, bool convert=false)
#define CMT_MID_RESETORIENTATION
XsensResultValue getDeviceMode2(CmtDeviceMode2 &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return device mode2.
XsensResultValue setLogMode(bool active)
Set the logging mode.
The namespace of all Xsens software since 2006.
XsensResultValue peekLogMessageId(uint8_t &messageId)
Open a communication channel to.
void setDataBuffer(const uint8_t *data, const uint16_t offset=0, const uint16_t count=0)
Write a string of bytes into the data buffer.
CmtDeviceConfiguration m_config
The configuration of the connected devices.
XsensResultValue resetOrientation(const CmtResetMethod method, const CmtDeviceId deviceId=CMT_DID_MASTER)
Perform an orientation reset on a device.
XsensResultValue getFirmwareRevision(CmtVersion &revision, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return Firmware revision.
XsensResultValue getSyncInSkipFactor(uint16_t &skipFactor)
Retrieve the inbound synchronization skip factor of an MT device.
CmtOutputSettings m_outputSettings
#define CMT_SYNC_CLOCK_TICKS_TO_NS
XsensResultValue getLogFileSize(CmtFilePos &size)
Retrieve the size of the open log file in bytes.
XsensResultValue getBluetoothState(bool &enabled)
Get the state of the bluetooth communication.
XsensResultValue closePort(bool gotoConfigFirst=true)
Close the communication port.
void setMessageId(const uint8_t msgId)
Set the new value of the m_messageId field and update the checksum.
XsensResultValue setScenario(const uint8_t scenarioType, const CmtDeviceId deviceId=CMT_DID_MASTER)
Specify the scenario to use in the sensor.
void setBusId(const uint8_t busId)
Set the new value of the m_busId field and update the checksum.
#define CMT_PARAM_SYNCOUT_PULSEWIDTH
#define CMT_MID_REQOUTPUTSETTINGS
#define CMT_PARAM_SYNCOUT_MODE
#define CMT_MID_REQOUTPUTSETTINGSACK
#define CMT_BAUD_RATE_921K6
#define CMT_SYNC_CLOCK_NS_TO_TICKS
void * m_eMtsData[CMT_MAX_DEVICES_PER_PORT]
Cached eMTS data.
XsensResultValue getBusPowerState(bool &enabled)
Get the state of the Xbus power.
uint16_t getSampleFrequency(void) const
Return the sample frequency in Hz.
A structure for storing device modes.
uint32_t m_masterDeviceId
CmtOutputMode m_outputMode
#define CMT_BAUD_RATE_19K2
XsensResultValue writeMessage(const Message *msg)
Write a message to the end of the file.
unsigned __int32 uint32_t
#define CMT_MID_GOTOCONFIG
XsensResultValue setSyncInOffset(const uint32_t offset)
Set the inbound synchronization offset of an MT device.
XsensResultValue getBaudrate(uint32_t &baudrate)
Get the baudrate used by a port.
#define CMT_MAX_DEVICES_PER_PORT
uint32_t getTimeOfDay(tm *date_, time_t *secs_)
A platform-independent clock.
uint32_t CmtDeviceId
The type of a Device Id.
#define CMT_BAUDCODE_19K2
XsensResultValue setHeading(const double heading, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the heading offset.
XsensResultValue setSyncOutMode(const uint16_t mode)
Set the outbound synchronization mode of an MT device.
uint16_t CmtMtTimeStamp
An MT timestamp (sample count)
A structure for storing scenario information.
uint8_t m_reservedForHost[32]
#define CMT_MID_REQPERIOD
uint16_t m_syncinSkipFactor
XsensResultValue getXmOutputMode(uint8_t &mode)
Return the dual-output mode of the XM.
void setDataByte(const uint8_t data, const uint16_t offset=0)
Write an unsigned byte (8 bits) into the data buffer.
XsensResultValue gotoConfig(void)
Place all connected devices into Configuration Mode.
Class for storing a single message.
uint16_t m_period
The sample period of the port.
#define CMT3_DEFAULT_TIMEOUT_CONF
The default timeout value for L3 configuration settings.
#define CMT_MID_SETSCENARIO
XsensResultValue setGotoConfigTries(const uint16_t tries)
Set the number of times the gotoConfig function will attempt a gotoConfig before failing.
#define CMT_MID_REQOPMODE
Cmt2f m_logFile
The (optional) CMT level 2 logfile object that this class operates on.
XsensResultValue flushData(void)
Flush all data to be transmitted / received.
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
XsensResultValue getGravityMagnitude(double &magnitude, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve the currently used magnitude of the gravity vector.
void setDataShort(const uint16_t data, const uint16_t offset=0)
Write an uint16_t (16 bits) into the data buffer.
XsensResultValue getSyncOutOffset(uint32_t &offset)
Retrieve the outbound synchronization offset of an MT device.
XsensResultValue readMessage(Message *rcv)
Read a message from the COM port.
#define CMT_MID_REQFILTERSETTINGS
Message m_msg
The message.
uint16_t m_outputSkipFactor