djiparsetxt
parseDetails.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 2021-05-20
18 
19  Copyright (c) 2021 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 the 'details' section in DJI ".txt" files.
23  Implementation.
24 */
25 
27 
28 void RecordAndDetailsParser::parseDetailsArea(u_int8_t const*& ptr, u_int8_t const* limit) {
29  // DETAILS.cityPart: string (length 20):
30  noteStringField("DETAILS.cityPart", ptr, 20, limit);
31 
32  // DETAILS.street: string (length 20):
33  noteStringField("DETAILS.street", ptr, 20, limit);
34 
35  // DETAILS.city: string (length 20):
36  noteStringField("DETAILS.city", ptr, 20, limit);
37 
38  // DETAILS.area: string (length 20):
39  noteStringField("DETAILS.area", ptr, 20, limit);
40 
41  // DETAILS.isFavorite: 1 byte unsigned:
42  noteByteField("DETAILS.isFavorite", ptr, limit);
43 
44  // DETAILS.isNew: 1 byte unsigned:
45  noteByteField("DETAILS.isNew", ptr, limit);
46 
47  // DETAILS.needsUpload: 1 byte unsigned:
48  noteByteField("DETAILS.needUpload", ptr, limit);
49 
50  // DETAILS.recordLineCount: 4 bytes little-endian unsigned::
51  note4ByteField("DETAILS.recordLineCount", ptr, limit);
52 
53  // unknown (4 bytes):
54  ptr += 4;
55 
56  // DETAILS.timestamp: 8 bytes little-endian, multiple of 0.001 seconds, in Unix time format:
57  note8ByteTimestampField("DETAILS.timestamp", ptr, limit, 1/*is in ms*/);
58 
59  // DETAILS.longitude: 8 bytes little-endian double, in degrees:
60  note8ByteDoubleField("DETAILS.longitude", ptr, limit);
61 
62  // DETAILS.latitude: 8 bytes little-endian double, in degrees:
63  note8ByteDoubleField("DETAILS.latitude", ptr, limit);
64 
65  // DETAILS.totalDistance: 4 bytes little-endian float:
66  note4ByteFloatField("DETAILS.totalDistance", ptr, limit);
67 
68  // DETAILS.totalTime: 4 bytes little-endian unsigned, multiple of 0.001m; convert to meters:
69  note4ByteField("DETAILS.totalTime", ptr, limit, 1000.0);
70 
71  // DETAILS.maxHeight: 4 bytes little-endian float:
72  note4ByteFloatField("DETAILS.maxHeight", ptr, limit);
73 
74  // DETAILS.maxHorizontalSpeed: 4 bytes little-endian float:
75  note4ByteFloatField("DETAILS.maxHorizontalSpeed", ptr, limit);
76 
77  // DETAILS.maxVerticalSpeed: 4 bytes little-endian float:
78  note4ByteFloatField("DETAILS.maxVerticalSpeed", ptr, limit);
79 
80  // DETAILS.photoNum: 4 bytes little-endian unsigned:
81  note4ByteField("DETAILS.photoNum", ptr, limit);
82 
83  // DETAILS.videoTime: 4 bytes little-endian unsigned:
84  note4ByteField("DETAILS.videoTime", ptr, limit);
85 
86  // The format from here on depends upon the file version:
87  extern u_int8_t fileVersionNumber;
88  if (fileVersionNumber < 0x06) {
89  // unknown (124 bytes)
90  ptr += 124;
91 
92  // DETAILS.aircraftSnBytes: string (length 10):
93  noteStringField("DETAILS.aircraftSn", ptr, 10, limit);
94 
95  // unknown (1 byte)
96  ++ptr;
97 
98  // DETAILS.aircraftName: string (length 25):
99  noteStringField("DETAILS.aircraftName", ptr, 25, limit);
100 
101  // unknown (7 bytes)
102  ptr += 7;
103 
104  // DETAILS.activeTimestamp: 8 bytes little-endian, in Unix time format:
105  note8ByteTimestampField("DETAILS.activeTimestamp", ptr, limit);
106 
107  // DETAILS.cameraSn: string (length 10):
108  noteStringField("DETAILS.cameraSn", ptr, 10, limit);
109 
110  // DETAILS.rcSn: string (length 10):
111  noteStringField("DETAILS.rcSn", ptr, 10, limit);
112 
113  // DETAILS.batterySn: string (length 10):
114  noteStringField("DETAILS.batterySn", ptr, 10, limit);
115  } else {
116  // Where is "DETAILS.activeTimestamp", and how is it formatted? #####
117  // unknown (137 bytes)
118  ptr += 137;
119 
120  // DETAILS.aircraftName: string (length 32):
121  noteStringField("DETAILS.aircraftName", ptr, 32, limit);
122 
123  // DETAILS.aircraftSnBytes: string (length 16):
124  noteStringField("DETAILS.aircraftSn", ptr, 16, limit);
125 
126  // DETAILS.cameraSn: string (length 16):
127  noteStringField("DETAILS.cameraSn", ptr, 16, limit);
128 
129  // DETAILS.rcSn: string (length 16):
130  noteStringField("DETAILS.rcSn", ptr, 16, limit);
131 
132  // DETAILS.batterySn: string (length 16):
133  noteStringField("DETAILS.batterySn", ptr, 16, limit);
134  }
135 
136  // DETAILS.appType.RAW: 1 byte unsigned:
137  noteByteField("DETAILS.appType.RAW", ptr, limit);
138 
139  // DETAILS.appVersion: 3 bytes:
140  note3ByteVersionField("DETAILS.appVersion", ptr, limit);
141 }
void note8ByteDoubleField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
virtual void parseDetailsArea(u_int8_t const *&ptr, u_int8_t const *limit)
u_int8_t fileVersionNumber
Definition: djiparsetxt.cpp:35
void note4ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int isSigned=0)
void note8ByteTimestampField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, int isInMilliseconds=0)
void note3ByteVersionField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
void noteStringField(char const *label, u_int8_t const *&ptr, unsigned stringLength, u_int8_t const *limit)
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)