Browse Source

AP_Logger: correct Write() containing 'a' entries

c415-sdk
Peter Barker 5 years ago committed by Peter Barker
parent
commit
031c97db30
  1. 7
      libraries/AP_Logger/AP_Logger_Backend.cpp
  2. 101
      libraries/AP_Logger/examples/AP_Logger_AllTypes/AP_Logger_AllTypes.cpp

7
libraries/AP_Logger/AP_Logger_Backend.cpp

@ -278,6 +278,13 @@ bool AP_Logger_Backend::Write(const uint8_t msg_type, va_list arg_list, bool is_
offset += sizeof(uint64_t); offset += sizeof(uint64_t);
break; break;
} }
case 'a': {
int16_t *tmp = va_arg(arg_list, int16_t*);
const uint8_t bytes = 32*2;
memcpy(&buffer[offset], tmp, bytes);
offset += bytes;
break;
}
} }
if (charlen != 0) { if (charlen != 0) {
char *tmp = va_arg(arg_list, char*); char *tmp = va_arg(arg_list, char*);

101
libraries/AP_Logger/examples/AP_Logger_AllTypes/AP_Logger_AllTypes.cpp

@ -48,13 +48,27 @@ enum MyLogMessages {
}; };
static const struct LogStructure log_structure[] = { static const struct LogStructure log_structure[] = {
{ LOG_FORMAT_MSG,
sizeof(log_Format),
"FMT",
"BBnNZ",
"Type,Length,Name,Format,Columns",
"-b---",
"-----" },
{ LOG_UNIT_MSG, sizeof(log_Unit),
"UNIT", "QbZ", "TimeUS,Id,Label", "s--","F--" },
{ LOG_FORMAT_UNITS_MSG, sizeof(log_Format_Units),
"FMTU", "QBNN", "TimeUS,FmtType,UnitIds,MultIds","s---", "F---" },
{ LOG_MULT_MSG, sizeof(log_Format_Multiplier),
"MULT", "Qbd", "TimeUS,Id,Mult", "s--","F--" },
{ LOG_TYP1_MSG, { LOG_TYP1_MSG,
sizeof(log_TYP1), sizeof(log_TYP1),
"TYP1", "TYP1",
"QbBhHiIfdnNZ", "QabBhHiIfdnNZ",
"TimeUS,b,B,h,H,i,I,f,d,n,N,Z", "TimeUS,a,b,B,h,H,i,I,f,d,n,N,Z",
"s-----------", "s------------",
"F-----------" "F------------"
}, },
{ LOG_TYP2_MSG, { LOG_TYP2_MSG,
sizeof(log_TYP2), sizeof(log_TYP2),
@ -118,10 +132,13 @@ void AP_LoggerTest_AllTypes::Log_Write_TypeMessages()
log_num = logger.find_last_log(); log_num = logger.find_last_log();
hal.console->printf("Using log number %u\n", log_num); hal.console->printf("Using log number %u\n", log_num);
struct log_TYP1 typ1 = { hal.console->printf("Writing out a few messages to get formats out...");
logger.Write_Message("Start 1");
struct log_TYP1 typ1{
LOG_PACKET_HEADER_INIT(LOG_TYP1_MSG), LOG_PACKET_HEADER_INIT(LOG_TYP1_MSG),
time_us : AP_HAL::micros64(), time_us : AP_HAL::micros64(),
a : { -32768, 32767, 1, -1, 0, 17 }, // int16[32] a : { -32768, 32767, 1, -1, 0, 19 }, // int16[32]
b : -17, // int8_t b : -17, // int8_t
B : 42, // uint8_t B : 42, // uint8_t
h : -12372, // int16_t h : -12372, // int16_t
@ -165,33 +182,55 @@ void AP_LoggerTest_AllTypes::Log_Write_TypeMessages_Log_Write()
log_num = logger.find_last_log(); log_num = logger.find_last_log();
hal.console->printf("Using log number for Log_Write %u\n", log_num); hal.console->printf("Using log number for Log_Write %u\n", log_num);
logger.Write("TYP3", TYP1_LBL, TYP1_FMT, hal.console->printf("Writing out a few messages to get formats out...");
AP_HAL::micros64(), logger.Write_Message("Start 2");
-17, // int8_t
42, // uint8_t logger.Write("TYPn",
-12372, // int16_t "TimeUS,Str",
19812, // uint16_t "Qn",
-98234729, // int32_t AP_HAL::micros64(),
74627293, // uint32_t "ABCD");
35.87654f, // float
(double)67.7393274658293, // double const int16_t a[32] = { -32768, 32767, 1, -1, 0, 17 };
"ABCD", // char[4]
// char[16]: logger.Write("TYPa",
"ABCDEFGHIJKLMNOP", "TimeUS,Arr",
// char[64]: "Qa",
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP" AP_HAL::micros64(),
a);
logger.Write("TYP3",
TYP1_LBL,
TYP1_FMT,
AP_HAL::micros64(),
a, // int16[32]
-17, // int8_t
42, // uint8_t
-12372, // int16_t
19812, // uint16_t
-98234729, // int32_t
74627293, // uint32_t
35.87654f, // float
(double)67.7393274658293, // double
"ABCD", // char[4]
// char[16]:
"ABCDEFGHIJKLMNOP",
// char[64]:
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
); );
logger.Write("TYP4", TYP2_LBL, TYP2_FMT, logger.Write("TYP4",
AP_HAL::micros64(), TYP2_LBL,
-9823, // int16_t * 100 TYP2_FMT,
5436, // uint16_t * 100 AP_HAL::micros64(),
-9209238, // int32_t * 100 -9823, // int16_t * 100
19239872, // uint32_t * 100 5436, // uint16_t * 100
-3576543, // uint32_t latitude/longitude; -9209238, // int32_t * 100
5, // uint8_t; // flight mode; 19239872, // uint32_t * 100
-98239832498328, // int64_t -3576543, // uint32_t latitude/longitude;
3432345232233432 // uint64_t 5, // uint8_t; // flight mode;
-98239832498328, // int64_t
3432345232233432 // uint64_t
); );
// emit a message which contains NaNs: // emit a message which contains NaNs:

Loading…
Cancel
Save