djiparsetxt
parseRecord_HOME.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 HOME records within DJI ".txt" files.
23  Implementation.
24 */
25 
27 
28 void RecordAndDetailsParser::parseRecord_HOME(u_int8_t const*& ptr, u_int8_t const* limit) {
29  // HOME.longitude: 8 bytes little-endian double, in radians; convert to degrees:
30  note8ByteLatitudeOrLongitudeFieldInRadians("HOME.longitude", ptr, limit);
31 
32  // HOME.latitude: 8 bytes little-endian double, in radians; convert to degrees:
33  note8ByteLatitudeOrLongitudeFieldInRadians("HOME.latitude", ptr, limit);
34 
35  // HOME.height: 4 bytes little-endian float, multiple of 0.1 meters; convert to meters:
36  note4ByteFloatField("HOME.height", ptr, limit, 10.0);
37 
38  // HOME.hasGoHome (1 bit) + HOME.goHomeStatus (3 bits) + HOME.isDynamicHomePointEnabled (1 bit) + HOME.aircraftHeadDirection (1 bit) + HOME.goHomeMode (1 bit) + HOME.isHomeRecord (1 bit):
39  u_int8_t byte = getByte(ptr, limit);
40  enterSubByteField("HOME.hasGoHome", byte, 0x80);
41  enterSubByteField("HOME.goHomeStatus", byte, 0x70);
42  enterSubByteField("HOME.isDynamicHomePointEnabled", byte, 0x08);
43  enterSubByteField("HOME.aircraftHeadDirection", byte, 0x04);
44  enterSubByteField("HOME.goHomeMode", byte, 0x02);
45  enterSubByteField("HOME.isHomeRecord", byte, 0x01);
46 
47  // HOME.iocMode.RAW (3 bits) + HOME.isIOCEnabled (1 bit) + HOME.isBeginnerMode (1 bit) + HOME.isCompassCeleing (1 bit) + HOME.compassCeleStatus (2 bits):
48  byte = getByte(ptr, limit);
49  enterSubByteField("HOME.iocMode.RAW", byte, 0xE0);
50  enterSubByteField("HOME.isIOCEnabled", byte, 0x10);
51  enterSubByteField("HOME.isBeginnerMode", byte, 0x08);
52  enterSubByteField("HOME.isCompassCeleing", byte, 0x04);
53  enterSubByteField("HOME.compassCeleStatus", byte, 0x03);
54 
55  // HOME.goHomeHeight: 2 bytes little-endian unsigned, meters:
56  noteUnsigned2ByteField("HOME.goHomeHeight", ptr, limit);
57 
58  // HOME.courseLockAngle: 2 bytes little-endian signed, multiple of 0.1 degrees, convert to degrees:
59  noteSigned2ByteField("HOME.courseLockAngle", ptr, limit, 10.0);
60 
61  // HOME.dataRecorderStatus: 1 byte unsigned:
62  noteByteField("HOME.dataRecorderStatus", ptr, limit);
63 
64  // HOME.dataRecorderRemainCapacity: 1 byte unsigned:
65  noteByteField("HOME.dataRecorderRemainCapacity", ptr, limit);
66 
67  // HOME.dataRecorderRemainTime: 2 bytes little-endian unsigned:
68  noteUnsigned2ByteField("HOME.dataRecorderRemainTime", ptr, limit);
69 
70  // HOME.dataRecorderFileIndex: 2 bytes little-endian unsigned:
71  noteUnsigned2ByteField("HOME.dataRecorderFileIndex", ptr, limit);
72 }
void parseRecord_HOME(u_int8_t const *&ptr, u_int8_t const *limit)
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 noteUnsigned2ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int16_t offset=0)
void note8ByteLatitudeOrLongitudeFieldInRadians(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
void enterSubByteField(char const *label, u_int8_t byte, u_int8_t mask)
void note4ByteFloatField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0)
void noteByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int isSigned=0)