UM001
39
Example Code
// 2D array to determine the payload length for a binary output packet. The first
// index of the array is the group number, and the second index
// is the group field index. Both indices are assumed to be zero based.
const unsigned char
groupLen[7][16] =
{
{8, 8, 8, 12, 16, 12, 24, 12, 12, 24, 20, 28, 2, 4, 8, 0},
//Group 1
{8, 8, 8, 2, 8, 8, 8, 4, 4, 1, 1, 0, 0, 0, 0, 0},
//Group 2
{2, 12, 12, 12, 4, 4, 16, 12, 12, 12, 12, 2, 40, 0, 0, 0},
//Group 3
{8, 8, 2, 1, 1, 24, 24, 12, 12, 12, 4, 4, 2, 28, 2, 12},
//Group 4
{2, 12, 16, 36, 12, 12, 12, 12, 12, 12, 28, 24, 0, 0, 0, 0},
//Group 5
{2, 24, 24, 12, 12, 12, 12, 12, 12, 4, 4, 68, 64, 0, 0, 0},
//Group 6
{8, 8, 2, 1, 1, 24, 24, 12, 12, 12, 4, 4, 2, 28, 2, 12},
//Group 7
};
4.3.7
Example Cases
To help you better understand how the binary protocol works, the next two sections provide an overview
of how the binary output packets are formed for two separate example cases.
Example Case 1
For example 1 we will assume that only binary group 1 is active, and only the yaw, pitch, and roll output
is active within this binary group. In this case the header will have the following form.
Header
Payload
CRC
Field
Sync
Group
Group 1
Fields
YawPitchRoll
CRC
Byte Offset
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Byte Value
(Hex)
FA
01
08
00
93
50
2E
42
83
3E
F1
3F
48
B5
04
BB
92
88
Type
u8
u8
u16
float
float
float
u16
Value
0xFA
1
8
0x422E5093
+43.578686 (Yaw)
0x3FF13E83
+1.8847202 (Pitch)
0xBB04B548
-2.0249654e-3 (Roll)
0x9288