djiparsetxt
parseRecord_GIMBAL.cpp
Go to the documentation of this file.
1 /**********
2 This program is free software: you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation, either version 3 of the License, or
5 (at your option) any later version.
6 
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11 
12 You should have received a copy of the GNU General Public License
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
14 **********/
15 /*
16  A C++ program to parse DJI's ".txt" log files (recorded by the "DJI Go 4" app).
17  Version 2019-02-08
18 
19  Copyright (c) 2019 Live Networks, Inc. All rights reserved.
20  For the latest version of this program (and more information), visit http://djilogs.live555.com
21 
22  Parsing GIMBAL records within DJI ".txt" files.
23  Implementation.
24 */
25 
27 
28 void RecordAndDetailsParser::parseRecord_GIMBAL(u_int8_t const*& ptr, u_int8_t const* limit) {
29  // GIMBAL.pitch: 2 bytes signed little-endian, multiple of 0.1 degrees; convert to degrees:
30  noteSigned2ByteField("GIMBAL.pitch", ptr, limit, 10.0);
31 
32  // GIMBAL.roll: 2 bytes signed little-endian, multiple of 0.1 degrees; convert to degrees:
33  noteSigned2ByteField("GIMBAL.roll", ptr, limit, 10.0);
34 
35  // GIMBAL.yaw: 2 bytes signed little-endian, multiple of 0.1 degrees; convert to degrees:
36  noteSigned2ByteField("GIMBAL.yaw", ptr, limit, 10.0);
37 
38  // GIMBAL.mode.RAW(2 bits) + unknown(6 bits):
39  u_int8_t byte = getByte(ptr, limit);
40  enterSubByteField("GIMBAL.mode.RAW", byte, 0xC0);
41 
42  // GIMBAL.rollAdjust: 1 byte signed, multiple of 0.1:
43  noteByteField("GIMBAL.rollAdjust", ptr, limit, 10.0, 1/*isSigned*/);
44 
45  // GIMBAL.yawAngle: 2 bytes signed little-endian, multiple of 0.1 degrees; convert to degrees:
46  noteSigned2ByteField("GIMBAL.yawAngle", ptr, limit, 10.0);
47 
48  // 8 bits (Boolean flags); from high to low:
49  // unknown
50  // GIMBAL.isStuck
51  // unknown
52  // GIMBAL.autoCalibrationResult
53  // GIMBAL.isAutoCalibration
54  // GIMBAL.isYawInLimit
55  // GIMBAL.isRollInLimit
56  // GIMBAL.isPitchInLimit
57  byte = getByte(ptr, limit);
58  enterSubByteField("GIMBAL.isStuck", byte, 0x40);
59  enterSubByteField("GIMBAL.autoCalibrationResult", byte, 0x10);
60  enterSubByteField("GIMBAL.isAutoCalibration", byte, 0x08);
61  enterSubByteField("GIMBAL.isYawInLimit", byte, 0x04);
62  enterSubByteField("GIMBAL.isRollInLimit", byte, 0x02);
63  enterSubByteField("GIMBAL.isPitchInLimit", byte, 0x01);
64 
65  // GIMBAL.isSingleClick (1 bit) + GIMBAL.isTripleClick (1 bit) + GIMBAL.isDoubleClick (1 bit) + unknown (1 bit) + GIMBAL.version (4 bits):
66  byte = getByte(ptr, limit);
67  enterSubByteField("GIMBAL.isSingleClick", byte, 0x80);
68  enterSubByteField("GIMBAL.isTripleClick", byte, 0x40);
69  enterSubByteField("GIMBAL.isDoubleClick", byte, 0x20);
70  enterSubByteField("GIMBAL.version", byte, 0x0F);
71 }
u_int8_t getByte(u_int8_t const *&ptr, u_int8_t const *limit)
void noteSigned2ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int16_t offset=0)
void enterSubByteField(char const *label, u_int8_t byte, u_int8_t mask)
void parseRecord_GIMBAL(u_int8_t const *&ptr, u_int8_t const *limit)
void noteByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int isSigned=0)