Binary packet structure¶
Table of Contents
Data transmitted and received by the UM7 is formatted into packets containing:
1. The three character start sequence
s n p to indicate the start
of a new packet (i.e. start new packet);
2. A packet type (PT) byte describing the function and length of the packet;
3. An address byte indicating the address of the register or command;
4. A sequence of data bytes, the length of which is specified in the PT byte;
5. A two-byte checksum for error-detection.
|
|
|
PT |
address |
D0 , D1 , …, DN-1 |
Checksum1 |
Checksum0 |
packet start |
type |
address |
data bytes |
Checksum |
|||
All binary packets sent and received by the UM7 must conform to the format given above.
The PT byte specifies whether the packet is a read or a write operation, whether it is a batch operation, and the length of the batch operation (when applicable). The PT byte is also used by the UM7 to respond to commands. The specific meaning of each bit in the PT byte is given below.
bit: |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
meaning: |
Has Data |
Is Batch |
BL3 |
BL2 |
BL1 |
BL0 |
hidden |
CF |
Bit(s) |
Description |
|---|---|
7 |
Has Data: If the packet contains data, this bit is set (1). If not, this bit is cleared (0). |
6 |
Is Batch: If the packet is a batch operation, this bit is set (1). If not, this bit is cleared (0). |
5:2 |
Batch Length (BL): Four bits specifying the length of the batch operation. Unused if bit 7 is cleared. The maximum batch length is therefore \(2^4 = 16\) |
1 |
Hidden: If set, then the packet address specified in the “address” field is a “hidden” address. Hidden registers are used to store factory calibration and filter tuning coefficients that do not typically need to be viewed or modified by the user. |
0 |
Command Failed (CF): Used by the autopilot to report when a command has failed. Must be set to zero for all packets written to the UM7. |
The address byte specifies which register will be involved in the operation:
During a read operation (Has Data = 0), the address specifies which register to read.
During a write operation (Has Data = 1), the address specifies where to place the data contained in the data section of the packet.
For a batch read/write operation, the address byte specifies the starting address of the operation.
The “Data Bytes” section of the packet contains data to be written to one or more registers. No byte in the packet states explicitly how many bytes are in this section because it is possible to determine the number of data bytes that should be in the packet by evaluating the PT byte.
If the “Has Data” bit in the PT byte is cleared (Has Data = 0), then there are no data bytes in the packet and the “Checksum” immediately follows the address. If, on the other hand, the “Has Data” bit is set (Has Data = 1) then the number of bytes in the data section depends on the value of the “Is Batch” and “Batch Length” portions of the PT byte.
For a batch operation (Is Batch = 1), the length of the packet data section is equal to:
Note that the batch length refers to the number of registers in the batch, NOT the number of bytes. Registers are \(4\) bytes long.
For a non-batch operation (Is Batch = 0), the length of the data section is equal to 4 bytes (one register). The data section lengths and total packet lengths for different PT configurations are shown below.
Has Data |
Is Batch |
Data Section Length (bytes) |
Total Packet Length (bytes) |
|---|---|---|---|
0 |
N/A |
0 |
7 |
1 |
0 |
4 |
11 |
1 |
1 |
\(4 \times (\text{Batch Length})\) |
\(7 + 4 \times (\text{Batch Length})\) |
Note that if a packet is a batch operation, the batch length must be greater than zero.
The two checksum bytes consist of the unsigned 16-bit sum of all preceding bytes in the packet, including the packet header.
Read Operations¶
To initiate a serial read of one or more registers aboard the sensor, a packet should be sent to the UM7 with the “Has Data” bit cleared. This tells the device that this will be a read operation from the address specified in the packet’s “Address” byte. If the “Is Batch” bit is set, then the packet will trigger a batch read in which the “Address” byte specifies the address of the first register to be read.
In response to a read packet, the UM7 will send a packet in which the “Has Data” bit is set, and the “Is Batch” and “Batch Length” bits are equivalent to those of the packet that triggered the read operation. The register data will be contained in the “Data Bytes” section of the packet.
Write Operations¶
To initiate a serial write into one or more registers aboard the sensor, a packet should be sent to the UM7 with the “Has Data” bit set. This tells the device that the incoming packet contains data that should be written to the register specified by the packet’s “Address” byte. If a batch write operation is to be performed, the “Is Batch” bit should be set, and the “Batch Length” bits should indicate the number of registers that are to be written to.
In response to a write packet,
the UM7 will update the contents of the specified register(s) with
the contents of the data section of the packet.
It will then transmit a COMMAND_COMPLETE packet to indicate
that the write operation succeeded.
A COMMAND_COMPLETE packet is a packet with PT = 0 (no data, no batch)
and with an address matching the address of the register
to which the write operation was made,
or the start address of the write operation if this was a batch write.
Note that the COMMAND_COMPLETE packet is equivalent to a packet
that would cause the autopilot to initiate a read operation on
the address to which data was just written.
Since the packet is going from the sensor to the host, however,
its meaning is different (it would not make sense for the autopilot
to request the contents of one of its registers from an external host).
Command Operations¶
There are a variety of register address that do not correspond with actual physical registers aboard the UM7. These “command” addresses are used to cause the sensor to execute specific commands (there are commands for executing calibration operations, resetting the onboard filters, etc. See the Register Overview in this document for more details).
To initiate a command, simply send a packet to the autopilot with the command’s address in the packet “Address” byte. The PT byte should be set to zero for a command operation.
If the UM7 successfully completes the specified command,
then a COMMAND_COMPLETE packet is returned with the command address
in the “Address” byte of the response packet.
If the command fails, the device responds by sending a COMMAND_FAILED packet.
The COMMAND_FAILED packet is equivalent to the COMMAND_COMPLETE packet except that the
“Command Failed” bit in the PT byte is set (CF = 1).
In some cases, a command will cause specific packets to be sent other than the
COMMAND_COMPLETE packet.
A GET_FW_VERSION command will, for example, return a packet containing the version
of the firmware installed on the UM7.
In this and similar cases, the COMMAND_COMPLETE packet is not sent.
Broadcasted packets¶
It is possible to configure the following packets to be sent periodically from the RSL board:
ALL_RAW_PACKET¶
The ALL_RAW_PACKET has the structure defined in the table below.
The Data Length of the packet is \(11\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
Reserved |
|
13 |
Reserved |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
Reserved |
|
25 |
Reserved |
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
Reserved |
|
37 |
Reserved |
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
Checksum 1 |
|
51 |
Checksum 2 |
RAW_GYRO_PACKET¶
The RAW_GYRO_PACKET has the structure defined in the table below.
The Data Length of the packet is \(3\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
Reserved |
|
13 |
Reserved |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
Checksum 1 |
|
19 |
Checksum 2 |
RAW_ACCEL_PACKET¶
The frequency of sending the RAW_ACCEL_PACKET broadcast messages
is defined by the field RAW_ACCEL_RATE in the CREG_COM_RATES1 register.
Note: if ALL_RAW_RATE field of the register CREG_COM_RATES2 is not 0, then
packet with all raw sensor data (ALL_RAW_PACKET) will be sent instead,
since ALL_RAW_PACKET has higher priority.
The RAW_ACCEL_PACKET has the structure defined in the table below.
The Data Length of the packet is \(3\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
Reserved |
|
13 |
Reserved |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
Checksum 1 |
|
19 |
Checksum 2 |
RAW_MAG_PACKET¶
The RAW_MAG_PACKET has the structure defined in the table below.
The Data Length of the packet is \(3\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
Reserved |
|
13 |
Reserved |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
Checksum 1 |
|
19 |
Checksum 2 |
RAW_TEMPERATURE_PACKET¶
The RAW_TEMPERATURE_PACKET has the structure defined in the table below.
The Data Length of the packet is \(2\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
Checksum 1 |
|
15 |
Checksum 2 |
ALL_PROC_PACKET¶
The ALL_PROC_PACKET has the structure defined in the table below.
The Data Length of the packet is \(12\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
Checksum 1 |
|
55 |
Checksum 2 |
PROC_GYRO_PACKET¶
The PROC_GYRO_PACKET has the structure defined in the table below.
The Data Length of the packet is \(4\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
Checksum 1 |
|
23 |
Checksum 2 |
PROC_ACCEL_PACKET¶
The PROC_ACCEL_PACKET has the structure defined in the table below.
The Data Length of the packet is \(4\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
Checksum 1 |
|
23 |
Checksum 2 |
PROC_MAG_PACKET¶
The PROC_MAG_PACKET has the structure defined in the table below.
The Data Length of the packet is \(4\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
Checksum 1 |
|
23 |
Checksum 2 |
EULER_PHI_THETA¶
The EULER_PHI_THETA has the structure defined in the table below.
The Data Length of the packet is \(5\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
Reserved |
|
13 |
Reserved |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
Reserved |
|
21 |
Reserved |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
Checksum 1 |
|
27 |
Checksum 2 |
HEALTH¶
The HEALTH has the structure defined in the table below.
The Data Length of the packet is \(1\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
Checksum 1 |
|
11 |
Checksum 2 |
QUATERNION¶
The QUATERNION has the structure defined in the table below.
The Data Length of the packet is \(3\), hence the packet total length:
Byte |
Content |
Register Payload |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Packet type |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
Checksum 1 |
|
19 |
Checksum 2 |