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 2018-07-20
18 
19  Copyright (c) 2018 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  int parseRecord_JPEG(u_int8_t const*& ptr, u_int8_t const* limit);
74  void parseRecordUnknownFormat(char const* recordTypeName, u_int8_t const*& ptr, u_int8_t const* limit);
75 
76  // Routines for parsing various types of fields within a record:
77  void enterSubByteField(char const* label, u_int8_t byte, u_int8_t mask);
78  void noteByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
79  float divisor = 0.0, int isSigned = 0);
80  // if "divisor" is not 0.0, divide the value by it, and store it as a float instead
81  void note2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
82  float divisor = 0.0, int16_t offset = 0, int isSigned = 0);
83  // first subtract "offset" from the value
84  // then, if "divisor" is not 0.0, divide the value by it, and store it as a float instead
85  void noteSigned2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
86  float divisor = 0.0, int16_t offset = 0) {
87  note2ByteField(label, ptr, limit, divisor, offset, 1);
88  }
89  void noteUnsigned2ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
90  float divisor = 0.0, int16_t offset = 0) {
91  note2ByteField(label, ptr, limit, divisor, offset, 0);
92  }
93  void note4ByteField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
94  float divisor = 0.0, int isSigned = 0);
95  // if "divisor" is not 0.0, divide the value by it, and store it as a float instead
96  void note4ByteFloatField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
97  float divisor = 0.0);
98  // if "divisor" is not 0.0, divide the value by it, before storing
99  void note8ByteDoubleField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
100  void note8ByteLatitudeOrLongitudeFieldInRadians(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
101  void note8ByteLatitudeOrLongitudeFieldInDegrees(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
102  void note2ByteDateField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
103  void note8ByteTimestampField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit,
104  int isInMilliseconds = 0);
105  void noteStringField(char const* label, u_int8_t const*& ptr, unsigned stringLength, u_int8_t const* limit);
106  void note3ByteVersionField(char const* label, u_int8_t const*& ptr, u_int8_t const* limit);
107 
108 private:
109  unsigned fNumRecords;
111  char const* fRecordTypeName[256];
113 
115 };
116 
117 #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_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_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)