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",
2118 "L3: setDeviceMode setting MT %08x output mode to %04X\n",
2141 "L3: setDeviceMode setting MT %08x output settings to %08X\n",
2219 CMT3LOG(
"L3: setMagneticDeclination %f %08x\n", declination,
deviceId);
2224 (
float)declination);
2232 CMT3LOG(
"L3: setXmPowerOff\n");
2322 CMT3LOG(
"L3: setSyncInSettings %u\n", skipFactor);
2392 "L3: setSyncOutSettings %u %u %u %u\n", (
uint32_t)settings.
m_mode,
2479 CMT3LOG(
"L3: setSyncOutSettings %u\n", pulseWidth);
2506 CMT3LOG(
"L3: setSyncOutSettings %u\n", skipFactor);
2559 CMT3LOG(
"L3: setTimeoutConfig %u\n", timeout);
2571 CMT3LOG(
"L3: setTimeoutMeasurement %u\n", timeout);
2596 CMT3LOG(
"L3: refreshCache %d\n", file ? 1 : 0);
2613 "L3: refreshCache Device in configuration mode, reading device "
2648 "L3: refreshCache Reading device configuration information from "
2676 CMT3LOGDAT(
"L3: waitForDataMessage %p\n", pack);
2720 "L3: createLogFile \"%s\" %u\n", filename ? filename :
"",
2721 startLogging ? 1 : 0);
2753 "L3: createLogFile \"%S\" %u\n", filename ? filename : L
"",
2754 startLogging ? 1 : 0);
2785 CMT3LOG(
"L3: closeLogFile %u\n", del ? 1 : 0);
2799 CMT3LOG(
"L3: isLogFileOpen \"%s\"\n", filename ? filename :
"");
2803 if (filename !=
nullptr && filename[0] != 0)
2818 CMT3LOG(
"L3: isLogFileOpen \"%S\"\n", filename ? filename : L
"");
2822 if (filename !=
nullptr && filename[0] != L
'\0')
2837 CMT3LOG(
"L3: openLogFile \"%s\"\n", filename ? filename :
"");
2860 CMT3LOG(
"L3: openLogFile \"%S\"\n", filename ? filename : L
"");
2883 CMT3LOG(
"L3: setDataSource %s\n", readFromFile ?
"file" :
"port");
2914 CMT3LOG(
"L3: setLogMode %u\n", active ? 1 : 0);
2926 CMT3LOG(
"L3: resetLogFileReadPos\n");
2935 CMT3LOG(
"L3: writeMessageToLogFile\n");
2970 scenarios[i].m_label,
3059 "L3: setGpsLeverArm [%f %f %f] %08x\n", arm.
m_data[0], arm.
m_data[1],
XsensResultValue flushData(void)
Flush all data to be transmitted / received.
uint8_t getPortNr(void) const
Retrieve the port number that was last successfully opened.
The mid-level file communication class.
XsensResultValue writeMessage(const Message *msg)
Write a message to the end of the file.
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...
CmtFilePos getFileSize(void)
Get the current file size.
CmtFilePos getReadPosition(void)
Get the current read position.
XsensResultValue close(void)
Close the file.
XsensResultValue closeAndDelete(void)
Close the file and delete it.
XsensResultValue create(const char *filename)
Create a new file with level 2 header.
XsensResultValue setReadPosition(CmtFilePos pos)
Set the read position to the given position.
XsensResultValue getName(char *filename) const
Retrieve the filename that was last successfully opened.
bool isOpen(void) const
Return whether the file is open or not.
XsensResultValue open(const char *filename, const bool readOnly=false)
Open a file and read the header.
Mid-level serial communication class.
XsensResultValue writeMessage(Message *msg)
Send a message over the COM port.
XsensResultValue getLastResult(void) const
Return the error code of the last operation.
bool isOpen(void) const
Return whether the communication port is open or not.
XsensResultValue close(void)
Close the serial communication port.
XsensResultValue setTimeout(const uint32_t ms=CMT2_DEFAULT_TIMEOUT)
Set the default timeout value to use in blocking operations.
XsensResultValue getPortNr(uint8_t &port) const
Retrieve the port that the object is connected to.
XsensResultValue readMessage(Message *rcv)
Read a message from the COM port.
XsensResultValue open(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
Open a communication channel to the given serial port name.
XsensResultValue waitForMessage(Message *rcv, const uint8_t msgId, uint32_t timeoutOverride, bool acceptErrorMessage)
Wait for a message to arrive.
XsensResultValue getPortName(char *portname) const
Cmt1s * getCmt1s(void)
Return a reference to the embedded Cmt1s object.
XsensResultValue setXmOutputMode(const uint8_t mode)
Set the dual-output mode of the XM.
XsensResultValue getSyncMode(uint8_t &mode)
Retrieve the sync mode of the Xbus Master.
XsensResultValue writeMessageToLogFile(const Message &msg)
uint16_t m_period
The sample period of the port.
XsensResultValue setBaudrate(const uint32_t baudrate, bool reconnect=true)
Set the baudrate and possibly reconnect.
CmtMtTimeStamp m_rtcLastSc
The last received sample counter, used to determine wrap-around.
XsensResultValue getEMtsData(void *buffer, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve the eMts data of the specified sensor(s).
bool isLogFileOpen(const char *filename) const
Return whether or not(true or false) the supplied file is open.
XsensResultValue storeXkfState(const CmtDeviceId deviceId=CMT_DID_MASTER)
Store important components of the XKF filter state to non-volatile memory.
uint32_t m_timeoutConf
The config mode timeout.
XsensResultValue setBusPowerState(const bool enabled)
Switch the Xbus Master bus power on or off.
XsensResultValue setSyncInOffset(const uint32_t offset)
Set the inbound synchronization offset of an MT device.
Cmt2s * getCmt2s(void)
Return a reference to the embedded Cmt2s (comm port) object.
uint32_t getTimeoutConfig(void) const
Return the configuration mode timeout.
XsensResultValue m_lastResult
The last result of an operation.
XsensResultValue getDeviceMode2(CmtDeviceMode2 &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return device mode2.
CmtDeviceConfiguration m_config
The configuration of the connected devices.
XsensResultValue setSyncOutOffset(const uint32_t offset)
Set the outbound synchronization offset of an MT device.
XsensResultValue setMagneticDeclination(const double declination, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the stored magnetic declination.
Cmt2f * getCmt2f(void)
Return a reference to the embedded Cmt2f (logfile) object.
uint16_t m_gotoConfigTries
The number of times a goto config is attempted before the function fails.
Cmt2f m_logFile
The (optional) CMT level 2 logfile object that this class operates on.
XsensResultValue waitForDataMessage(Packet *pack)
Wait for a data message to arrive.
uint32_t m_baudrate
The baudrate that was last set to be used by the port.
XsensResultValue setLogMode(bool active)
Set the logging mode.
~Cmt3()
Destructor, de-initializes, frees memory allocated for buffers, etc.
XsensResultValue setBluetoothState(const bool enabled)
Set the Bluetooth state of the Xbus Master.
XsensResultValue getSyncInOffset(uint32_t &offset)
Retrieve the inbound synchronization offset of an MT device.
void fillRtc(Packet *pack)
Internal function to compute the RTC value.
XsensResultValue getDataLength(uint32_t &length, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve data size.
bool isXm(void) const
Return whether the main device is an Xbus Master or not.
Cmt3()
Default constructor, initializes all members to their default values.
XsensResultValue getDeviceId(const uint8_t busId, CmtDeviceId &deviceId) const
Retrieve the DeviceId of a device given its Bus ID.
XsensResultValue getSerialBaudrate(uint32_t &baudrate)
Return the baud rate used for serial communication.
XsensResultValue closePort(bool gotoConfigFirst=true)
Close the communication port.
XsensResultValue getUtcTime(CmtUtcTime &utc, const CmtDeviceId deviceId)
Return the UTC time of the last received sample.
uint32_t m_timeoutMeas
The measurement mode timeout.
bool m_readFromFile
Indicates whether to read from the log file or from the serial port.
XsensResultValue getBluetoothState(bool &enabled)
Get the state of the bluetooth communication.
void clearHwError(void)
Reset the hardware error code.
XsensResultValue getSyncOutPulseWidth(uint32_t &pulseWidth)
Retrieve the outbound synchronization pulse width of an MT device.
bool m_rtcInitialized
Indicates if the rtc is initialised or not.
XsensResultValue getConfiguration(CmtDeviceConfiguration &configuration)
Get device configuration.
XsensResultValue getSyncOutOffset(uint32_t &offset)
Retrieve the outbound synchronization offset of an MT device.
XsensResultValue setDeviceMode2(const CmtDeviceMode2 &mode, bool force, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the complete output mode2 of a device.
XsensResultValue setGpsLeverArm(const CmtVector &arm, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the currently used GPS lever arm.
XsensResultValue getLogFileName(char *filename)
Retrieve the name of the open log file or an empty string if no logfile is open.
XsensResultValue setLocationId(uint16_t locationId, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the location ID of a sensor.
CmtDeviceId getMasterId(void)
void * m_eMtsData[CMT_MAX_DEVICES_PER_PORT]
Cached eMTS data.
XsensResultValue getDeviceMode(CmtDeviceMode &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return device mode.
XsensResultValue gotoConfig(void)
Place all connected devices into Configuration Mode.
XsensResultValue openLogFile(const char *filename)
Open a log file for input.
XsensResultValue restoreFactoryDefaults(const CmtDeviceId deviceId=CMT_DID_MASTER)
Restore the device to factory default settings.
XsensResultValue getSyncOutSettings(CmtSyncOutSettings &settings)
Retrieve the outbound synchronization settings of the master MT device.
XsensResultValue resetLogFileReadPos(void)
Restart reading from the start of the open log file.
bool m_useRtc
Indicates if the RTC should be computed or not (to save CPU time).
XsensResultValue closeLogFile(bool del=false)
Close an open log file.
XsensResultValue getHeading(double &heading, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the heading offset.
XsensResultValue gotoMeasurement(void)
Place all connected devices into Measurement Mode.
XsensResultValue initBus(void)
Perform an initBus request.
XsensResultValue peekLogMessageId(uint8_t &messageId)
Open a communication channel to.
XsensResultValue m_lastHwError
Contains the last error reported by hardware.
XsensResultValue getPortNr(uint8_t &port) const
Return the device Id of an MT device.
XsensResultValue getBusPowerState(bool &enabled)
Get the state of the Xbus power.
XsensResultValue openPort(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
XsensResultValue getBaudrate(uint32_t &baudrate)
Get the baudrate used by a port.
XsensResultValue getGravityMagnitude(double &magnitude, const CmtDeviceId deviceId=CMT_DID_MASTER)
Retrieve the currently used magnitude of the gravity vector.
XsensResultValue getAvailableScenarios(CmtScenario *scenarios, const CmtDeviceId deviceId=CMT_DID_MASTER)
Write the specified message to the open.
XsensResultValue createLogFile(const char *filename, bool startLogging=false)
Create a log file for incoming messages.
XsensResultValue getLogFileReadPosition(CmtFilePos &pos)
Retrieve the read position of the log file.
XsensResultValue getProductCode(char *productCode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return product code.
XsensResultValue getScenario(uint8_t &scenarioType, uint8_t &scenarioVersion, const CmtDeviceId deviceId=CMT_DID_MASTER)
Get the currently active scenario from a Motion Tracker.
XsensResultValue getMagneticDeclination(double &declination, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the stored magnetic declination.
bool m_measuring
Keeps track of whether the connected device is measuring or being configured.
XsensResultValue setSyncInSkipFactor(const uint16_t skipFactor)
Set the inbound synchronization skip factor of an MT device.
XsensResultValue setSyncOutSettings(const CmtSyncOutSettings &settings)
Set the outbound synchronization settings of an MT device.
XsensResultValue setTimeoutConfig(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_CONF)
Set the configuration mode timeout.
XsensResultValue getFirmwareRevision(CmtVersion &revision, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return Firmware revision.
XsensResultValue setTimeoutMeasurement(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_MEAS)
Set the measurement mode timeout.
uint16_t getSampleFrequency(void)
Return current sample frequency.
XsensResultValue readDataPacket(Packet *pack, bool acceptOther=false)
Retrieve a data message.
uint16_t getMtCount(void) const
Return the device Id of the first.
XsensResultValue setSyncOutSkipFactor(const uint16_t skipFactor)
Set the outbound synchronization skip factor of an MT device.
XsensResultValue getErrorMode(uint16_t &mode, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the error mode of the device.
XsensResultValue refreshCache(const bool file=false)
Update device information stored on host PC.
XsensResultValue getSyncOutSkipFactor(uint16_t &skipFactor)
Retrieve the outbound synchronization skip factor of an MT device.
uint16_t m_skip
The skip factor of the port.
XsensResultValue getGpsStatus(CmtGpsStatus &status, const CmtDeviceId deviceId=CMT_DID_MASTER)
Request the status of the GPS satellites in orbit.
XsensResultValue setGotoConfigTries(const uint16_t tries)
Set the number of times the gotoConfig function will attempt a gotoConfig before failing.
XsensResultValue getBusId(uint8_t &busId, const CmtDeviceId deviceId=CMT_DID_MASTER) const
Retrieve the BusId of a device.
XsensResultValue getMtDeviceId(const uint8_t index, CmtDeviceId &deviceId) const
XsensResultValue setSyncInSettings(const CmtSyncInSettings &settings)
Set the inbound synchronization settings of an MT device.
XsensResultValue getSyncInSettings(CmtSyncInSettings &settings)
Retrieve the inbound synchronization settings of the master MT device.
CmtDeviceId m_lastHwErrorDeviceId
Contains the Device ID of the device that caused the last hardware error.
double m_rtcMsPerSample
ms per sample = 1000 / sample frequency.
XsensResultValue setHeading(const double heading, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the heading offset.
TimeStamp m_rtcStart
The start of the RTC counter, the time of arrival of sample 0.
XsensResultValue getBatteryLevel(uint8_t &level)
Get an Xbus Master's battery level.
XsensResultValue setSyncMode(const uint8_t mode)
Set the sync mode of the Xbus Master.
Cmt2s m_serial
The (optional) CMT level 2 serial object that this class operates on.
XsensResultValue requestData(Packet *pack)
XsensResultValue getGpsLeverArm(CmtVector &arm, const CmtDeviceId deviceId=CMT_DID_MASTER)
Get the currently used GPS lever arm.
XsensResultValue setScenario(const uint8_t scenarioType, const CmtDeviceId deviceId=CMT_DID_MASTER)
Specify the scenario to use in the sensor.
uint32_t getDeviceCount(void) const
Retrieve total device count.
XsensResultValue reset(void)
Request a data.
bool m_logging
Indicates whether to write all received messages to the logfile or not, automatically set to true by ...
XsensResultValue setDataSource(bool readFromFile)
Set whether to read from comm port or file.
XsensResultValue setSyncInMode(const uint16_t mode)
Set the inbound synchronization mode of an MT device.
XsensResultValue setSyncOutPulseWidth(const uint32_t pulseWidth)
Set the outbound synchronization pulse width of an MT device.
XsensResultValue getLogFileSize(CmtFilePos &size)
Retrieve the size of the open log file in bytes.
XsensResultValue getXmOutputMode(uint8_t &mode)
Return the dual-output mode of the XM.
uint32_t getTimeoutMeasurement(void) const
Return the measurement mode timeout.
XsensResultValue getSyncOutMode(uint16_t &mode)
Retrieve the outbound synchronization mode of an MT device.
XsensResultValue setGravityMagnitude(const double magnitude, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the currently used magnitude of the gravity vector.
XsensResultValue setXmPowerOff(void)
Switch the connected Xbus Master.
XsensResultValue setSyncOutMode(const uint16_t mode)
Set the outbound synchronization mode of an MT device.
XsensResultValue resetOrientation(const CmtResetMethod method, const CmtDeviceId deviceId=CMT_DID_MASTER)
Perform an orientation reset on a device.
uint8_t getBusIdInternal(const CmtDeviceId devId) const
Find a device Id in the list and return its busId.
XsensResultValue setDeviceMode(const CmtDeviceMode &mode, bool force, const CmtDeviceId deviceId=CMT_DID_MASTER)
Set the complete output mode of a device.
XsensResultValue setErrorMode(const uint16_t mode)
Set the error mode of the device.
XsensResultValue getSyncInMode(uint16_t &mode)
Retrieve the inbound synchronization mode of an MT device.
XsensResultValue getSyncInSkipFactor(uint16_t &skipFactor)
Retrieve the inbound synchronization skip factor of an MT device.
uint32_t m_rtcCount
The long sample counter (normal counter wraps at 64k).
XsensResultValue getLocationId(uint16_t &locationId, const CmtDeviceId deviceId=CMT_DID_MASTER)
Return the location ID of a sensor.
Class for storing a single message.
void setDataLong(const uint32_t data, const uint16_t offset=0)
Write an uint32_t (32 bits) into the data buffer.
uint8_t getDataByte(const uint16_t offset=0) const
Return the current value of the data as an unsigned byte (8 bits).
uint32_t getDataLong(const uint16_t offset=0) const
Return the current value of the data as an uint32_t (32 bits).
uint8_t * getDataBuffer(const uint16_t offset=0)
Return a pointer to the data buffer.
uint16_t getDataSize(void) const
Return the length of the data part of the message.
uint16_t getDataShort(const uint16_t offset=0) const
Return the current value of the data as an uint16_t (16 bits).
void setDataFloat(const float data, const uint16_t offset=0)
Write a float (32 bits) into the data buffer.
uint8_t getMessageId(void) const
Return the current value of the m_messageId field.
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.
void setDataByte(const uint8_t data, const uint16_t offset=0)
Write an unsigned byte (8 bits) into the data buffer.
void setDataShort(const uint16_t data, const uint16_t offset=0)
Write an uint16_t (16 bits) into the data buffer.
float getDataFloat(const uint16_t offset=0) const
Return the current value of the data as a float (32 bits).
void setBusId(const uint8_t busId)
Set the new value of the m_busId field and update the checksum.
void setMessageId(const uint8_t msgId)
Set the new value of the m_messageId field and update the checksum.
const uint8_t * getMessageStart(void) const
Return the start of the message buffer.
void recomputeChecksum(void)
Compute the checksum field and fill it.
void resizeData(const uint16_t newSize)
Resize the data area to the given size.
A structure containing MT data + timestamp and formatting information.
void setXbus(bool xbus, bool convert=false)
TimeStamp m_toa
Time of arrival.
uint16_t m_itemCount
The number of data items in the message.
Message m_msg
The message.
TimeStamp m_rtc
Sample time in ms, based on the sample counter.
bool setDataFormat(const CmtDataFormat &format, const uint16_t index=0)
uint16_t getSampleCounter(const uint16_t index=0) const
Return the Sample Counter component of the packet.
#define DO_DATA_REQUEST(req)
#define DO_DATA_SET(req, size, type, data)
#define DO_DATA_SET_BID(req, size, type, data, bid)
#define HANDLE_ERR_RESULT
#define DO_DATA_REQUEST_BID(req, bid)
#define CMT_MID_SETGRAVITYMAGNITUDE
#define CMT_MID_REQDATALENGTH
#define CMT_MID_SETMAGNETICDECLINATION
#define CMT_MID_SETGPSLEVERARM
#define CMT_PARAM_SYNCIN_MODE
#define CMT_MID_REQOUTPUTSKIPFACTORACK
#define CMT_MID_REQOPMODE
#define CMT_DID_TYPEH_MTI_MTX
#define CMT_MAX_DEVICES_PER_PORT
#define CMT_LEN_ERRORMODE
#define CMT_MID_REQUTCTIME
#define CMT_BAUD_RATE_921K6
#define CMT_LEN_GPSLEVERARM
#define CMT_MID_REQXMERRORMODE
#define CMT_MID_GOTOCONFIGACK
#define CMT_PARAM_SYNCOUT_MODE
uint32_t CmtDeviceId
The type of a Device Id.
#define CMT_OUTPUTSETTINGS_TIMESTAMP_MASK
#define CMT_MAX_SCENARIOS_IN_MT
#define CMT_MID_REQPRODUCTCODE
#define CMT_MID_REQSYNCINSETTINGSACK
#define CMT_PARAM_SYNCIN_SKIPFACTOR
#define CMT_BAUD_RATE_19K2
#define CMT_LEN_BTDISABLE
#define CMT_MID_REQBAUDRATE
#define CMT_BAUD_RATE_230K4
#define CMT_BAUDCODE_38K4
#define CMT_BAUDCODE_115K2
#define CMT_MID_REQOUTPUTSKIPFACTOR
#define CMT_MID_REQOUTPUTSETTINGSACK
#define CMT_MID_STOREXKFSTATE
#define CMT_LEN_RESETORIENTATION
#define CMT_MID_REQFILTERSETTINGSACK
#define CMT_LEN_LOCATIONID
#define CMT_BAUDCODE_460K8
#define CMT_MID_SETSCENARIO
#define CMT_MID_REQOUTPUTMODEACK
#define CMT_MID_GOTOMEASUREMENTACK
#define CMT_CONF_BLOCKLEN
#define CMT_MID_REQSYNCOUTSETTINGS
#define CMT_BAUDCODE_19K2
#define CMT_MID_REQGPSSTATUS
#define CMT_BID_BROADCAST
#define CMT_BAUD_RATE_115K2
#define CMT_MID_REQMAGNETICDECLINATION
#define CMT_MID_REQFILTERSETTINGS
#define CMT_SYNC_CLOCK_TICKS_TO_NS
#define CMT_MID_REQHEADING
#define CMT_PARAM_SYNCOUT_PULSEWIDTH
#define CMT_LEN_SCENARIOLABEL
#define CMT_MID_STOREXKFSTATEACK
#define CMT_MID_REQPERIODACK
#define CMT_LEN_GRAVITYMAGNITUDE
#define CMT3_DEFAULT_TIMEOUT_CONF
The default timeout value for L3 configuration settings.
#define CMT_DID_TYPEH_MASK
#define CMT_LEN_SETSCENARIO
#define CMT_BAUD_RATE_57K6
#define CMT_MID_RESETORIENTATION
#define CMT_MID_REQSYNCMODE
#define CMT_MID_REQERRORMODE
#define CMT_MID_GOTOCONFIG
#define CMT_BAUD_RATE_9600
#define CMT_BAUDCODE_921K6
#define CMT_MID_GOTOMEASUREMENT
#define CMT_BAUDCODE_57K6
#define CMT_MID_REQGRAVITYMAGNITUDE
#define CMT_MID_REQCONFIGURATION
#define CMT_GOTO_CONFIG_TRIES
#define CMT_MID_REQBATLEVEL
uint16_t CmtMtTimeStamp
An MT timestamp (sample count)
#define CMT3_CONFIG_TIMEOUT
The timeout value for "goto config"-message acknowledgement.
#define CMT_MID_RESTOREFACTORYDEF
#define CMT_SYNC_CLOCK_NS_TO_TICKS
#define CMT_MID_REQGPSLEVERARM
#define CMT_MID_REQAVAILABLESCENARIOS
#define CMT_BAUD_RATE_460K8
#define CMT_MID_REQSYNCINSETTINGS
#define CMT_DID_TYPEH_MTIG
#define CMT_PARAM_SYNCOUT_SKIPFACTOR
#define CMT_MID_REQSYNCOUTSETTINGSACK
#define CMT_MID_REQBTDISABLE
#define CMT_PARAM_SYNCOUT_OFFSET
#define CMT_DID_BROADCAST
#define CMT_MID_REQPERIOD
#define CMT_LEN_MAGNETICDECLINATION
#define CMT_LEN_STOREXKFSTATE
#define CMT_MID_SETGPSLEVERARMACK
#define CMT_MID_REQOUTPUTSETTINGS
#define CMT_PARAM_SYNCIN_OFFSET
#define CMT_MID_REQLOCATIONID
#define CMT_MID_REQOUTPUTMODE
#define CMT_BAUDCODE_230K4
#define CMT_MID_CONFIGURATION
#define CMT3_DEFAULT_TIMEOUT_MEAS
The default timeout value for L3 data reading.
#define CMT_DEFAULT_PERIOD
#define CMT_BAUD_RATE_38K4
#define CMT_MAX_FILENAME_LENGTH
#define CMT_MID_REQSCENARIO
GLuint GLsizei GLsizei * length
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
The namespace of all Xsens software since 2006.
uint32_t getTimeOfDay(tm *date_, time_t *secs_)
A platform-independent clock.
TimeStamp timeStampNow(void)
void msleep(uint32_t ms)
A platform-independent sleep routine.
uint64_t TimeStamp
A real-time timestamp (ms)
unsigned __int16 uint16_t
unsigned __int32 uint32_t
uint32_t m_outputSettings
Structure containing a full device configuration as returned by the ReqConfig message.
uint16_t m_numberOfDevices
uint32_t m_masterDeviceId
struct CmtDeviceConfiguration::_devInfo m_deviceInfo[CMT_MAX_DEVICES_PER_PORT]
uint8_t m_reservedForHost[32]
uint16_t m_outputSkipFactor
void readFromMessage(const void *message)
uint16_t m_samplingPeriod
uint16_t m_syncinSkipFactor
uint8_t m_reservedForClient[32]
A structure for storing device modes using period and skip factor (new default)
uint16_t getSampleFrequency(void) const
Return the sample frequency in Hz.
CmtOutputSettings m_outputSettings
double getRealSampleFrequency(void) const
Return the real sample frequency in Hz.
CmtOutputMode m_outputMode
bool operator==(const CmtDeviceMode2 &dev) const
Check if all fields of the two structures are equal.
void setSampleFrequency(uint16_t freq)
Compute the period and skip factor from a sample frequency.
A structure for storing device modes.
uint16_t m_sampleFrequency
void getPeriodAndSkipFactor(uint16_t &period, uint16_t &skip) const
Compute the period and skip factor.
CmtOutputSettings m_outputSettings
bool operator==(const CmtDeviceMode &dev) const
Check if all fields of the two structures are equal.
double getRealSampleFrequency(void) const
Return the real sample frequency in Hz.
CmtOutputMode m_outputMode
void setPeriodAndSkipFactor(uint16_t period, uint16_t skip)
Compute the sample frequency from a period and skip factor.
A structure for storing scenario information.
uint8_t m_type
The type of the scenario.
char m_filterType
The type of filter this scenario is intended for '3': XKF-3, '6': XKF-6.
uint8_t m_version
The version of the scenario.
char m_label[CMT_LEN_SCENARIOLABEL+1]
The label of the scenario.
A structure for storing sync in settings.
uint32_t m_offset
Offset in ns.
A structure for storing sync out settings.
uint32_t m_pulseWidth
Pulse width in ns.
uint32_t m_offset
Offset in ns.
A structure for storing UTC Time values.
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...
A structure for storing the firmware version.
const char * xsensResultText(const XsensResultValue result)
XsensResultValue
Xsens return values.
@ XRV_OK
Operation was performed successfully.
#define XSENS_MS_PER_DAY
The number of milliseconds in a normal day.