Go to the documentation of this file.
73 #define XS_IND_PREAMBLE 0
77 #define XS_IND_DATA0 4
78 #define XS_IND_LENEXTH 4
79 #define XS_IND_LENEXTL 5
80 #define XS_IND_DATAEXT0 6
82 #define XS_SELFTEST_OK 0x1FF
85 #define XS_LEN_TRANSPORTMODE 1
86 #define XS_LEN_DEVICEID 4
87 #define XS_LEN_INITBUSRESULTS 4
88 #define XS_LEN_PERIOD 2
89 #define XS_LEN_BUSPWR 2
90 #define XS_LEN_DATALENGTH 2
91 #define XS_LEN_CONFIGURATION 118
92 #define XS_LEN_FIRMWAREREV 3
93 #define XS_LEN_BTDISABLE 1
94 #define XS_LEN_OPMODE 1
95 #define XS_LEN_BAUDRATE 1
96 #define XS_LEN_SYNCMODE 1
97 #define XS_LEN_PRODUCTCODE 20
98 #define XS_LEN_PROCESSINGFLAGS 2
99 #define XS_LEN_XMPWROFF 0
100 #define XS_LEN_OUTPUTMODE 2
101 #define XS_LEN_OUTPUTSETTINGS 4
102 #define XS_LEN_OUTPUTSKIPFACTOR 2
103 #define XS_LEN_SYNCINMODE 2
104 #define XS_LEN_SYNCINSKIPFACTOR 2
105 #define XS_LEN_SYNCINOFFSET 4
106 #define XS_LEN_SYNCOUTMODE 2
107 #define XS_LEN_SYNCOUTSKIPFACTOR 2
108 #define XS_LEN_SYNCOUTOFFSET 4
109 #define XS_LEN_SYNCOUTPULSEWIDTH 4
110 #define XS_LEN_ERRORMODE 2
111 #define XS_LEN_TRANSMITDELAY 2
112 #define XS_LEN_OBJECTALIGNMENT 36
113 #define XS_LEN_XMERRORMODE 2
114 #define XS_LEN_BUFFERSIZE 2
115 #define XS_LEN_HEADING 4
116 #define XS_LEN_MAGNETICFIELD 12
117 #define XS_LEN_LOCATIONID 2
118 #define XS_LEN_EXTOUTPUTMODE 2
119 #define XS_LEN_INITTRACKMODE 2
120 #define XS_LEN_STOREFILTERSTATE 0
121 #define XS_LEN_UTCTIME 12
122 #define XS_LEN_FILTERPROFILELABEL 20
123 #define XS_LEN_FILTERPROFILEFULL (1+1+XS_LEN_FILTERPROFILELABEL)
124 #define XS_LEN_AVAILABLEFILTERPROFILES (XS_MAX_FILTERPROFILES_IN_MT*XS_LEN_FILTERPROFILEFULL)
125 #define XS_LEN_REQFILTERPROFILEACK 2
126 #define XS_LEN_SETFILTERPROFILE 2
127 #define XS_LEN_GRAVITYMAGNITUDE 4
128 #define XS_LEN_GNSSLEVERARM 12
129 #define XS_LEN_LATLONALT 18
130 #define XS_LEN_SETNOROTATION 2
131 #define XS_LEN_FILTERSETTINGS 4
133 #define XS_LEN_RESETORIENTATION 2
134 #define XS_LEN_GNSSSTATUS (1+5*16)
135 #define XS_LEN_CLIENTUSAGE 1
136 #define XS_LEN_CLIENTPRIORITY 1
137 #define XS_LEN_WIRELESSCONFIG 6
138 #define XS_LEN_INFOREQUEST 1
139 #define XS_LEN_SETOUTPUTTRIGGER 10
140 #define XS_LEN_SETINPUTTRIGGER 10
144 #define XS_LEN_RAWDATA 20
145 #define XS_LEN_CALIBDATA 36
146 #define XS_LEN_CALIB_ACCDATA 12
147 #define XS_LEN_CALIB_GYRDATA 12
148 #define XS_LEN_CALIB_MAGDATA 12
149 #define XS_LEN_ORIENT_QUATDATA 16
150 #define XS_LEN_ORIENT_EULERDATA 12
151 #define XS_LEN_ORIENT_MATRIXSTA 36
152 #define XS_LEN_SAMPLECNT 2
153 #define XS_LEN_TEMPDATA 4
156 #define XS_LEN_CALIBDATA_FLT 9
157 #define XS_LEN_TEMPDATA_FLT 1
158 #define XS_LEN_ORIENT_QUATDATA_FLT 4
159 #define XS_LEN_ORIENT_EULERDATA_FLT 3
160 #define XS_LEN_ORIENT_MATRIXSTA_FLT 9
162 #pragma pack(push, 1)
203 register uint8_t sum = 0;
204 for (; count; --count, sum += *(buffer++));
252 case sizeof(uint16_t):
255 memcpy((
void*)&
i16,
data,
sizeof(uint16_t));
257 memcpy(
data, (
void*)&
i16,
sizeof(uint16_t));
268 case sizeof(uint64_t):
271 memcpy((
void*)&
i64,
data,
sizeof(uint64_t));
273 memcpy(
data, (
void*)&
i64,
sizeof(uint64_t));
303 memcpy(dest, value, size);
317 msgSize = dataSize + 5;
319 msgSize = dataSize + 7;
322 memset(thisPtr->
m_message.m_data, 0, msgSize);
332 thisPtr->
m_checksum[0] = (uint8_t) - (int8_t)(uint8_t)dataSize;
561 rv.
d = ((double) tmp) / 1048576.0;
562 rv.
i64 = (rv.
i64 & ~1LL) | (tmp & 1);
583 rv.
d = (double) fp.
i64 / 4294967296.0;
584 rv.
i64 = (rv.
i64 & ~1LL) | (fpfrac & 1);
692 dexp = ((fp.
i32.
i0 & (0x7fffffffL)) >> 20) - 1023;
700 fp.
i64 = fp.
i64 >> (20 - dexp);
710 fpint = ((int16_t)(uint16_t)(0x8000));
801 for (i = 0; i < numValues; i++)
842 for (i = 0; i < numValues; i++)
884 for (i = 0; i < numValues; i++)
889 #ifdef XSENS_SINGLE_PRECISION
898 #ifdef XSENS_SINGLE_PRECISION
907 #ifdef XSENS_SINGLE_PRECISION
916 #ifdef XSENS_SINGLE_PRECISION
941 for (i = 0; i < numValues; i++)
980 for (i = 1; i < msgSize; ++i)
1037 uint8_t* oldData, *newData;
1040 if (oldSize == newSize)
1071 if (oldSize > newSize)
1073 for (index = 0; index < oldSize; ++index)
1074 newData[index] = oldData[index];
1127 XsSize index, oldSize, newSize;
1130 uint8_t* oldData, *newData;
1136 newSize = oldSize + count;
1138 if (newSize < offset + count)
1139 newSize = offset + count;
1163 if (offset <= oldSize)
1165 for (index = 0; index < offset; ++index)
1166 newData[index] = oldData[index];
1170 for (index = 0; index < oldSize; ++index)
1171 newData[index] = oldData[index];
1172 for (; index < offset; ++index)
1175 for (; index < oldSize; ++index)
1176 newData[index + count] = oldData[index];
1191 XsSize index, oldSize, newSize;
1194 uint8_t* oldData, *newData;
1197 if (!count || offset >= oldSize)
1200 if (offset + count >= oldSize)
1205 newSize = oldSize - count;
1229 for (index = 0; index < offset; ++index)
1230 newData[index] = oldData[index];
1231 for (; index < newSize; ++index)
1232 newData[index] = oldData[index + count];
1282 if (maxBytes == 0 || maxBytes > i)
1288 s = (
char*) resultValue->m_data;
1289 for (i = 0; i < maxBytes - 1; ++i)
1290 sprintf(
s + (i * 3),
"%02X ", (
unsigned int)((uint8_t
const*) thisPtr->
m_message.m_data)[i]);
1291 sprintf(
s + ((maxBytes - 1) * 3),
"%02X", (
unsigned int)((uint8_t
const*) thisPtr->
m_message.m_data)[maxBytes - 1]);
#define XS_BID_MASTER
The bus identifier of the master device.
void XsMessage_deleteData(XsMessage *thisPtr, XsSize count, XsSize offset)
Remove count bytes of data from the message at offset.
void XsMessage_getDataFPValuesById(XsMessage const *thisPtr, XsDataIdentifier dataIdentifier, double *dest, XsSize offset, XsSize numValues)
Return current data values as double, conversion depends on outputSetting.
void XsMessage_getEndianCorrectData(XsMessage const *thisPtr, void *value, XsSize size, XsSize offset)
Get data of size size at offset, and put it byteswapped into value.
void XsMessage_setDataFPValuesById(XsMessage *thisPtr, XsDataIdentifier dataIdentifier, double const *data, XsSize offset, XsSize numValues)
Write a number of floating/fixed point values into to the data buffer, conversion depends on outputSe...
void XsMessage_assign(XsMessage *thisPtr, XsSize dataSize)
This function reinitializes the XsMessage object and reserves dataSize bytes for data.
void XsMessage_setBusId(XsMessage *thisPtr, uint8_t busId)
Set the bus id for this message to busId.
int XsArray_compare(void const *a, void const *b)
Returns non-zero if the lists are different, 0 if they're equal.
void XsMessage_swap(XsMessage *a, XsMessage *b)
Swap the contents of a and b.
A list of uint8_t values.
double XsMessage_getDataFP1632(XsMessage const *thisPtr, XsSize offset)
Returns the F16.32 value at offset in the data of the message.
void XsMessage_insertData(XsMessage *thisPtr, XsSize count, XsSize offset)
Create count bytes of empty space at offset in this message.
void XsByteArray_construct(XsByteArray *thisPtr, XsSize count, uint8_t const *src)
void XsMessage_constructSized(XsMessage *thisPtr, XsSize dataSize)
This function initializes the XsMessage object and reserves dataSize bytes for data.
@ XDI_SubFormatFp1632
Fixed point 16.32.
void XsMessage_setEndianCorrectData(XsMessage *thisPtr, void const *value, XsSize size, XsSize offset)
Set value value of size size byteswapped at offset.
void XsArray_destruct(void *thisPtr)
Clears and frees memory allocated by the XsArray.
#define swapEndian64(src)
static float convertToFloat(double d)
static const uint8_t * XsMessage_cdataAtOffset(XsMessage const *thisPtr, XsSize offset)
return the const data at offset offset
static void XsMessage_updateChecksumWithValue(XsMessage *thisPtr, const void *value, XsSize sizeofValue, XsSize offset)
Update the message checksum with the passed value.
static double convertFromFloat(float f)
static uint8_t * XsMessage_dataAtOffset(XsMessage *thisPtr, XsSize offset)
Get the buffer at offset offset.
uint64_t XsMessage_getDataLongLong(XsMessage const *thisPtr, XsSize offset)
Returns the long value at offset in the data of the message.
void XsMessage_recomputeChecksum(XsMessage *thisPtr)
Update the checksum for the message.
void XsArray_copy(void *thisPtr, void const *src)
Copy the contents of src to thisArray.
void XsMessage_setDataFP1632(XsMessage *thisPtr, double value, XsSize offset)
Sets the F16.32 at offset in the message to value.
@ XDI_SubFormatFp1220
Fixed point 12.20.
uint8_t XsMessage_computeChecksum(XsMessage const *thisPtr)
Computes the checksum for the message.
XsSize XsMessage_getTotalMessageSize(XsMessage const *thisPtr)
Return the length of the message buffer.
void XsMessage_setMessageId(XsMessage *thisPtr, enum XsXbusMessageId msgId)
Set the message id for this message to msgId.
void XsMessage_getDataRealValuesById(XsMessage const *thisPtr, XsDataIdentifier dataIdentifier, XsReal *dest, XsSize offset, XsSize numValues)
Return current data values as XsReal, conversion is done automatically based on data identifier.
uint8_t byteSum(const uint8_t *buffer, XsSize count)
Calculate the sum of the values in the buffer.
void XsMessage_resizeData(XsMessage *thisPtr, XsSize newSize)
Resize the buffer of message to newSize bytes.
#define XSBYTEARRAY_INITIALIZER
const uint8_t * XsMessage_getDataBuffer(XsMessage const *thisPtr, XsSize offset)
Returns a const pointer to the data buffer of the message.
uint8_t XsMessage_getDataByte(XsMessage const *thisPtr, XsSize offset)
Returns the byte value at offset in the data of the message.
int XsMessage_isChecksumOk(XsMessage const *thisPtr)
Returns non-zero if the checksum inside the message is correct for the message, zero otherwise.
void XsMessage_toHexString(XsMessage const *thisPtr, XsSize maxBytes, XsString *resultValue)
Return a string containing the first maxBytes bytes of the message in hex format.
void XsMessage_setDataLongLong(XsMessage *thisPtr, uint64_t value, XsSize offset)
Sets the long at offset in the message to value.
void XsMessage_setDataShort(XsMessage *thisPtr, uint16_t value, XsSize offset)
Sets the short at offset in the message to value.
XsDataIdentifier
Defines the data identifiers.
void XsArray_copyConstruct(void *thisPtr, void const *src)
Initializes the XsArray with a copy of src.
void XsMessage_copyConstruct(XsMessage *thisPtr, XsMessage const *src)
Construct an XsMessage as a copy of XsMessage src.
void XsMessage_load(XsMessage *thisPtr, XsSize msgSize, unsigned char const *src)
This function initializes the XsMessage object and reserves msgSize bytes for data,...
void XsMessage_setDataBuffer(XsMessage *thisPtr, const uint8_t *buffer, XsSize size, XsSize offset)
Puts size number of bytes from buffer into the message at offset.
XsSize XsMessage_dataSize(XsMessage const *thisPtr)
This function returns the datasize of the message in thisptr.
uint8_t *const m_checksum
Points to the checksum to speed up automatic checksum updates.
double XsReal
Defines the floating point type used by the Xsens libraries.
const XsMessageHeader * XsMessage_getConstHeader(XsMessage const *thisPtr)
void XsArray_swap(void *a, void *b)
Swap the contents of a with those of b.
#define swapEndian32(src)
@ XDI_SubFormatDouble
Double format.
void XsMessage_setDataLong(XsMessage *thisPtr, uint32_t value, XsSize offset)
Sets the long at offset in the message to value.
uint8_t XsMessage_getFPValueSize(XsDataIdentifier id)
Returns the byte size of id if the format is a floating point format.
void XsMessage_copy(XsMessage *copy, XsMessage const *thisPtr)
This function copies from thisPtr to copy.
size_t XsSize
XsSize must be unsigned number!
void XsMessage_setDataF1220(XsMessage *thisPtr, double value, XsSize offset)
Sets the F12.20 at offset in the message to value.
XsXbusMessageId
Xsens Xbus Message Identifiers.
int XsMessage_empty(XsMessage const *thisPtr)
Test if this message is empty.
void XsMessage_construct(XsMessage *thisPtr)
This function initializes the XsMessage object.
Structure for storing a single message.
double XsMessage_getDataF1220(XsMessage const *thisPtr, XsSize offset)
Returns the F12.20 value at offset in the data of the message.
static void XsMessage_ensureDataSize(XsMessage *thisPtr, XsSize offset, XsSize sizeofValue)
Make sure the data buffer is large enough to hold a new data item of sizeofValue.
@ XDI_SubFormatFloat
Floating point format.
@ XDI_SubFormatMask
Determines, float, fp12.20, fp16.32, double output... (where applicable)
void XsMessage_setDataDouble(XsMessage *thisPtr, double value, XsSize offset)
Sets the double at offset in the message to value.
void XsString_resize(XsString *thisPtr, XsSize count)
This function resizes the contained string to the desired size, while retaining its contents.
void XsMessage_setDataByte(XsMessage *thisPtr, uint8_t value, XsSize offset)
Set the byte at offset in the message to value.
uint32_t XsMessage_getDataLong(XsMessage const *thisPtr, XsSize offset)
Returns the long value at offset in the data of the message.
void XsMessage_destruct(XsMessage *thisPtr)
This function clears the data in the message.
int XsMessage_compare(XsMessage const *a, XsMessage const *b)
Compare the contents of the messages a and b, returning non-0 if they are different.
const uint8_t * XsMessage_getMessageStart(XsMessage const *thisPtr)
This function returns a const pointer to the header of the message in thisptr.
XsMessageHeader * XsMessage_getHeader(XsMessage *thisPtr)
Returns a pointer to the message header for this message.
const uint8_t * XsMessage_constData(XsMessage const *thisPtr, XsSize offset)
This function returns a const pointer to the offset in the data of the message in thisptr.
float XsMessage_getDataFloat(XsMessage const *thisPtr, XsSize offset)
Returns the float value at offset in the data of the message.
#define swapEndian16(src)
double XsMessage_getDataDouble(XsMessage const *thisPtr, XsSize offset)
Returns the double at offset in the data of the message.
A 0-terminated managed string of characters.
void XsMessage_setDataRealValuesById(XsMessage *thisPtr, XsDataIdentifier dataIdentifier, XsReal const *data, XsSize offset, XsSize numValues)
Write a number of floating/fixed point values into to the data buffer, conversion depends on data ide...
void XsMessage_setDataFloat(XsMessage *thisPtr, float value, XsSize offset)
Sets the float at offset in the message to value.
uint16_t XsMessage_getDataShort(XsMessage const *thisPtr, XsSize offset)
Returns the short value at offset in the data of the message.
static void swapEndian(void *data, const XsSize size)
Swap the endianness based on the data size.