djiparsetxt
RecordAndDetailsParser.hh
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 records (and the 'details' section) within DJI ".txt" files.
23  Header File.
24 */
25 
26 #ifndef _RECORD_AND_DETAILS_PARSER_HH
27 #define _RECORD_AND_DETAILS_PARSER_HH
28 
29 #ifndef _DJI_TXT_PARSER_HH
30 #include "DJITxtParser.hh"
31 #endif
32 
33 #ifndef _FIELD_DATABASE_HH
34 #include "FieldDatabase.hh"
35 #endif
36 
38 public:
40 
41 public:
43 };
44 
46 public:
48  virtual ~RecordAndDetailsParser();
49 
50  int parseJPEGRecord(u_int8_t const*& ptr, u_int8_t const* limit);
51 
52 private: // redefined virtual functions:
53  virtual void parseDetailsArea(u_int8_t const*& ptr, u_int8_t const* limit);
54  virtual int parseRecord(u_int8_t const*& ptr, u_int8_t const* limit, int isScrambled);
55  virtual void summarizeRecordParsing();
56  virtual void outputOneRow(int outputColumnLabels);
57 
58 private:
59  // Routines for parsing specific types of record:
60  void parseRecord_OSD(u_int8_t const*& ptr, u_int8_t const* limit);
61  void parseRecord_HOME(u_int8_t const*& ptr, u_int8_t const* limit);
62  void parseRecord_GIMBAL(u_int8_t const*& ptr, u_int8_t const* limit);
63  void parseRecord_RC(u_int8_t const*& ptr, u_int8_t const* limit);
64  void parseRecord_CUSTOM(u_int8_t const*& ptr, u_int8_t const* limit);
65  void parseRecord_DEFORM(u_int8_t const*& ptr, u_int8_t const* limit);
66  void parseRecord_CENTER_BATTERY(u_int8_t const*& ptr, u_int8_t const* limit);
67  void parseRecord_SMART_BATTERY(u_int8_t const*& ptr, u_int8_t const* limit);
68  void parseRecord_APP_TIP(u_int8_t const*& ptr, u_int8_t const* limit);
69  void parseRecord_APP_WARN(u_int8_t const*& ptr, u_int8_t const* limit);
70  void parseRecord_RECOVER(u_int8_t const*& ptr, u_int8_t const* limit);
71  void parseRecord_APP_GPS(u_int8_t const*& ptr, u_int8_t const* limit);
72  void parseRecord_FIRMWARE(u_int8_t const*& ptr, u_int8_t const* limit);
73  void parseRecord_APP_SER_WARN(u_int8_t const*& ptr, u_int8_t const* limit);
74  void parseRecord_COMPONENT(u_int8_t const*& ptr, u_int8_t const* limit);
75  int parseRecord_JPEG(u_int8_t const*& ptr, u_int8_t const* limit);
76  void parseRecordUnknownFormat(char const* recordTypeName, u_int8_t const*& ptr, u_int8_t const* limit);
77 
78  // Routines for parsing various types of fields within a record:
79  void enterSubByteField(char const* label, u_int8_t byte, u_int8_t mask);
80  void noteByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
81  float divisor = 0.0, int isSigned = 0);
82  // if "divisor" is not 0.0, divide the value by it, and store it as a float instead
83  void note2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
84  float divisor = 0.0, int16_t offset = 0, int isSigned = 0);
85  // first subtract "offset" from the value
86  // then, if "divisor" is not 0.0, divide the value by it, and store it as a float instead
87  void noteSigned2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
88  float divisor = 0.0, int16_t offset = 0) {
89  note2ByteField(label, ptr, limit, divisor, offset, 1);
90  }
91  void noteUnsigned2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
92  float divisor = 0.0, int16_t offset = 0) {
93  note2ByteField(label, ptr, limit, divisor, offset, 0);
94  }
95  void note4ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
96  float divisor = 0.0, int isSigned = 0);
97  // if "divisor" is not 0.0, divide the value by it, and store it as a float instead
98  void note4ByteFloatField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
99  float divisor = 0.0);
100  // if "divisor" is not 0.0, divide the value by it, before storing
101  void note8ByteDoubleField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
102  void note8ByteLatitudeOrLongitudeFieldInRadians(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
103  void note8ByteLatitudeOrLongitudeFieldInDegrees(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
104  void note2ByteDateField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
105  void note8ByteTimestampField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
106  int isInMilliseconds = 0);
107  void noteStringField(char const* label, u_int8_t const*& ptr, unsigned stringLength, u_int8_t const* limit);
108  void note3ByteVersionField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
109 
110 private:
111  unsigned fNumRecords;
113  char const* fRecordTypeName[256];
115 
117 };
118 
119 #endif
void parseRecord_HOME(u_int8_t const *&ptr, u_int8_t const *limit)
int parseJPEGRecord(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 note8ByteDoubleField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
RecordTypeStat fRecordTypeStats[256]
void parseRecord_RECOVER(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_APP_GPS(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecordUnknownFormat(char const *recordTypeName, u_int8_t const *&ptr, u_int8_t const *limit)
virtual void summarizeRecordParsing()
void noteUnsigned2ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int16_t offset=0)
void parseRecord_APP_WARN(u_int8_t const *&ptr, u_int8_t const *limit)
virtual int parseRecord(u_int8_t const *&ptr, u_int8_t const *limit, int isScrambled)
Definition: parseRecord.cpp:62
virtual void parseDetailsArea(u_int8_t const *&ptr, u_int8_t const *limit)
void note8ByteLatitudeOrLongitudeFieldInDegrees(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_COMPONENT(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_CENTER_BATTERY(u_int8_t const *&ptr, u_int8_t const *limit)
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 parseRecord_CUSTOM(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_DEFORM(u_int8_t const *&ptr, u_int8_t const *limit)
void note4ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int isSigned=0)
void parseRecord_APP_TIP(u_int8_t const *&ptr, u_int8_t const *limit)
void note8ByteTimestampField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, int isInMilliseconds=0)
int parseRecord_JPEG(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_RC(u_int8_t const *&ptr, u_int8_t const *limit)
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 note2ByteField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0, int16_t offset=0, int isSigned=0)
void parseRecord_APP_SER_WARN(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_SMART_BATTERY(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_GIMBAL(u_int8_t const *&ptr, u_int8_t const *limit)
void note4ByteFloatField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit, float divisor=0.0)
virtual void outputOneRow(int outputColumnLabels)
Definition: rowOutput.cpp:39
void parseRecord_FIRMWARE(u_int8_t const *&ptr, u_int8_t const *limit)
void parseRecord_OSD(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)
void note2ByteDateField(char const *label, u_int8_t const *&ptr, u_int8_t const *limit)