Browse Source

AP_Logger: move documentation for fieldtypes, units and mults to top

master
Peter Barker 6 years ago committed by Peter Barker
parent
commit
b644df14d0
  1. 172
      libraries/AP_Logger/LogStructure.h

172
libraries/AP_Logger/LogStructure.h

@ -1,69 +1,28 @@
#pragma once #pragma once
/* /*
unfortunately these need to be macros because of a limitation of Format characters in the format string for binary log messages
named member structure initialisation in g++ a : int16_t[32]
*/ b : int8_t
#define LOG_PACKET_HEADER uint8_t head1, head2, msgid; B : uint8_t
#define LOG_PACKET_HEADER_INIT(id) head1 : HEAD_BYTE1, head2 : HEAD_BYTE2, msgid : id h : int16_t
#define LOG_PACKET_HEADER_LEN 3 // bytes required for LOG_PACKET_HEADER H : uint16_t
i : int32_t
// once the logging code is all converted we will remove these from I : uint32_t
// this header f : float
#define HEAD_BYTE1 0xA3 // Decimal 163 d : double
#define HEAD_BYTE2 0x95 // Decimal 149 n : char[4]
N : char[16]
// structure used to define logging format Z : char[64]
struct LogStructure { c : int16_t * 100
uint8_t msg_type; C : uint16_t * 100
uint8_t msg_len; e : int32_t * 100
const char *name; E : uint32_t * 100
const char *format; L : int32_t latitude/longitude
const char *labels; M : uint8_t flight mode
const char *units; q : int64_t
const char *multipliers; Q : uint64_t
};
// maximum lengths of fields in LogStructure, including trailing nulls
static const uint8_t LS_NAME_SIZE = 5;
static const uint8_t LS_FORMAT_SIZE = 17;
static const uint8_t LS_LABELS_SIZE = 65;
static const uint8_t LS_UNITS_SIZE = 17;
static const uint8_t LS_MULTIPLIERS_SIZE = 17;
/*
log structures common to all vehicle types
*/ */
struct PACKED log_Format {
LOG_PACKET_HEADER;
uint8_t type;
uint8_t length;
char name[4];
char format[16];
char labels[64];
};
struct PACKED log_Unit {
LOG_PACKET_HEADER;
uint64_t time_us;
char type;
char unit[64]; // you know, this might be overkill...
};
struct PACKED log_Format_Multiplier {
LOG_PACKET_HEADER;
uint64_t time_us;
char type;
double multiplier;
};
struct PACKED log_Format_Units {
LOG_PACKET_HEADER;
uint64_t time_us;
uint8_t format_type;
char units[16];
char multipliers[16];
};
struct UnitStructure { struct UnitStructure {
const char ID; const char ID;
@ -140,6 +99,71 @@ const struct MultiplierStructure log_Multipliers[] = {
{ '/', 3600 }, // (ampere*second => ampere*hour) { '/', 3600 }, // (ampere*second => ampere*hour)
}; };
/*
unfortunately these need to be macros because of a limitation of
named member structure initialisation in g++
*/
#define LOG_PACKET_HEADER uint8_t head1, head2, msgid;
#define LOG_PACKET_HEADER_INIT(id) head1 : HEAD_BYTE1, head2 : HEAD_BYTE2, msgid : id
#define LOG_PACKET_HEADER_LEN 3 // bytes required for LOG_PACKET_HEADER
// once the logging code is all converted we will remove these from
// this header
#define HEAD_BYTE1 0xA3 // Decimal 163
#define HEAD_BYTE2 0x95 // Decimal 149
// structure used to define logging format
struct LogStructure {
uint8_t msg_type;
uint8_t msg_len;
const char *name;
const char *format;
const char *labels;
const char *units;
const char *multipliers;
};
// maximum lengths of fields in LogStructure, including trailing nulls
static const uint8_t LS_NAME_SIZE = 5;
static const uint8_t LS_FORMAT_SIZE = 17;
static const uint8_t LS_LABELS_SIZE = 65;
static const uint8_t LS_UNITS_SIZE = 17;
static const uint8_t LS_MULTIPLIERS_SIZE = 17;
/*
log structures common to all vehicle types
*/
struct PACKED log_Format {
LOG_PACKET_HEADER;
uint8_t type;
uint8_t length;
char name[4];
char format[16];
char labels[64];
};
struct PACKED log_Unit {
LOG_PACKET_HEADER;
uint64_t time_us;
char type;
char unit[64]; // you know, this might be overkill...
};
struct PACKED log_Format_Multiplier {
LOG_PACKET_HEADER;
uint64_t time_us;
char type;
double multiplier;
};
struct PACKED log_Format_Units {
LOG_PACKET_HEADER;
uint64_t time_us;
uint8_t format_type;
char units[16];
char multipliers[16];
};
struct PACKED log_Parameter { struct PACKED log_Parameter {
LOG_PACKET_HEADER; LOG_PACKET_HEADER;
uint64_t time_us; uint64_t time_us;
@ -1212,30 +1236,6 @@ struct PACKED log_Arm_Disarm {
#define ARSP_UNITS "snPOPP----" #define ARSP_UNITS "snPOPP----"
#define ARSP_MULTS "F00B00----" #define ARSP_MULTS "F00B00----"
/*
Format characters in the format string for binary log messages
a : int16_t[32]
b : int8_t
B : uint8_t
h : int16_t
H : uint16_t
i : int32_t
I : uint32_t
f : float
d : double
n : char[4]
N : char[16]
Z : char[64]
c : int16_t * 100
C : uint16_t * 100
e : int32_t * 100
E : uint32_t * 100
L : int32_t latitude/longitude
M : uint8_t flight mode
q : int64_t
Q : uint64_t
*/
// messages for all boards // messages for all boards
#define LOG_BASE_STRUCTURES \ #define LOG_BASE_STRUCTURES \
{ LOG_FORMAT_MSG, sizeof(log_Format), \ { LOG_FORMAT_MSG, sizeof(log_Format), \

Loading…
Cancel
Save