djiparsetxt
parseRecord_CENTER_BATTERY.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 CENTER_BATTERY records within DJI ".txt" files.
23  Implementation.
24 */
25 
27 
28 void RecordAndDetailsParser::parseRecord_CENTER_BATTERY(u_int8_t const*& ptr, u_int8_t const* limit) {
29  // CENTER_BATTERY.relativeCapacity: 1 byte unsigned:
30  noteByteField("CENTER_BATTERY.relativeCapacity", ptr, limit);
31 
32  // CENTER_BATTERY.currentPV: 2 bytes unsigned little-endian; multiple of 0.001 volts; convert to volts:
33  noteUnsigned2ByteField("CENTER_BATTERY.currentPV", ptr, limit, 1000.0);
34 
35  // CENTER_BATTERY.currentCapacity: 2 bytes unsigned little-endian:
36  noteUnsigned2ByteField("CENTER_BATTERY.currentCapacity", ptr, limit);
37 
38  // CENTER_BATTERY.fullCapacity: 2 bytes unsigned little-endian:
39  noteUnsigned2ByteField("CENTER_BATTERY.fullCapacity", ptr, limit);
40 
41  // CENTER_BATTERY.life: 1 byte unsigned:
42  noteByteField("CENTER_BATTERY.life", ptr, limit);
43 
44  // CENTER_BATTERY.loopNum: 2 bytes unsigned little-endian:
45  noteUnsigned2ByteField("CENTER_BATTERY.loopNum", ptr, limit);
46 
47  // CENTER_BATTERY.errorType: 4 bytes unsigned little-endian:
48  note4ByteField("CENTER_BATTERY.errorType", ptr, limit);
49 
50  // CENTER_BATTERY.current: 2 bytes unsigned little-endian, multiple of 0.001 amps; convert to amps:
51  noteUnsigned2ByteField("CENTER_BATTERY.current", ptr, limit, 1000.0);
52  // CHECK VALUE! #####
53 
54  // CENTER_BATTERY.voltageCell(1 through 6): 2 bytes unsigned little-endian, multiple of 0.001 volts; convert to volts:
55  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell1", ptr, limit, 1000.0);
56  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell2", ptr, limit, 1000.0);
57  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell3", ptr, limit, 1000.0);
58  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell4", ptr, limit, 1000.0);
59  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell5", ptr, limit, 1000.0);
60  noteUnsigned2ByteField("CENTER_BATTERY.voltageCell6", ptr, limit, 1000.0);
61 
62  // CENTER_BATTERY.serialNo: 2 bytes unsigned little-endian:
63  noteUnsigned2ByteField("CENTER_BATTERY.serialNo", ptr, limit);
64 
65  // CENTER_BATTERY.productDate: 2 bytes little-endian: 7 bits (years since 1980) + 4 bits (month) + 5 bits (day of month):
66  note2ByteDateField("CENTER_BATTERY.productDate", ptr, limit);
67 
68  // CENTER_BATTERY.temperature: 2 bytes unsigned little-endian, multiple of 0.01 C; convert to C:
69  noteUnsigned2ByteField("CENTER_BATTERY.temperature", ptr, limit, 100.0);
70  // CHECK VALUE #####
71 
72  // CENTER_BATTERY.connStatus.RAW: 1 byte unsigned:
73  noteByteField("CENTER_BATTERY.connStatus.RAW", ptr, limit);
74 }
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_CENTER_BATTERY(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 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)