x-IMU3 User Manual v0.11
April 6, 2022
7.3
File contents
The contents of the file is a byte stream as per the communication protocol described in Section 8. Each file
starts with a preamble of the following messages, in order.
1. Ping response
2. Write time command
3. Write setting command for each setting
8
Communication protocol
All communication interfaces use the same communication protocol. The byte stream is therefore identical
for USB, serial, Transmission Control Protocol (TCP), User Datagram Protocol (UDP), Bluetooth, and the files
created by the data logger. The communication protocol consists of two message types:
·
Command messages
·
Data messages
All messages are terminated by a Line Feed (LF) control character. This termination byte will not appear
anywhere else in a message and so can be used to divide a byte stream into individual messages. Some
messages are terminated with an additional Carriage Return (CR) control character. Table 10 describes the
different ways that the control characters LF and CR may be referred to throughout this document.
Control character
Abbreviation
String
Hex
Decimal
Line Feed
“
\
n”
0x0A
10
Carriage Return
“
\
r”
0x0D
13
Table 10: Control characters LF and CR representations
The first byte of a message indicates the message type. Command messages start with the character “
{
”
(0x7B in hex, 123 in decimal). Data messages start with either an uppercase character or a byte value
greater than 0x80 (128 in decimal) depending on the message.
8.1
Command messages
Command messages are sent to the device to read and write settings and execute commands. All command
messages are a JavaScript Object Notation (JSON) object containing a single key/value pair, terminated by
the control character sequence: CR, LF. The control character LF must not appear anywhere else in a
command message. The device will acknowledge each received command message by sending a command
message with the same key to the host.
The key used by command messages sent to the device is not case sensitive and can use non-alphanumeric
characters arbitrarily. For example, “serialNumber”, “Serial Number”, and “serial number” are all valid keys
for a command message to read the device serial number. The key used by the acknowledgement command
message sent from the device to the host will always be in camel case. For example, “serialNumber”.
8.1.1
Read setting command
The read setting command is sent to the device to read a setting value. The key is the setting key and the
value is null. See Section 11.1 on page 33 for a complete list of settings. The device will acknowledge a read
setting command by sending a write setting command to the host.
Example:
{
"serialNumber":null
}\
r
\
n
18