From 709a277c7ff03e88b1f11ea4eeebd56c9e506aa4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Apr 2013 19:46:22 +1000 Subject: [PATCH] DataFlash: chamged FMT message to include labels this makes it easier for MP to parse and display --- libraries/DataFlash/DataFlash.h | 13 ++++------ libraries/DataFlash/DataFlash_File.cpp | 2 -- libraries/DataFlash/LogFile.cpp | 33 ++++++++++---------------- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 70d71893d5..3aa285370c 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -64,13 +64,6 @@ public: }; protected: - /* - print column headers - */ - void _print_format_headers(uint8_t num_types, - const struct LogStructure *structure, - AP_HAL::BetterStream *port); - /* read and print a log entry using the format strings from the given structure */ @@ -115,6 +108,7 @@ Format characters in the format string for binary log messages f : float n : char[4] N : char[16] + Z : char[64] c : int16_t * 100 C : uint16_t * 100 e : int32_t * 100 @@ -141,6 +135,7 @@ struct PACKED log_Format { uint8_t length; char name[4]; char format[16]; + char labels[64]; }; struct PACKED log_Parameter { @@ -170,8 +165,8 @@ struct PACKED log_IMU { }; #define LOG_COMMON_STRUCTURES \ - { LOG_FORMAT_MSG, sizeof(log_Parameter), \ - "FMT", "BBnN", "Type,Length,Name,Format" }, \ + { LOG_FORMAT_MSG, sizeof(log_Format), \ + "FMT", "BBnNZ", "Type,Length,Name,Format" }, \ { LOG_PARAMETER_MSG, sizeof(log_Parameter), \ "PARM", "Nf", "Name,Value" }, \ { LOG_GPS_MSG, sizeof(log_GPS), \ diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index 9b24a28e0c..9826816a9f 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -319,8 +319,6 @@ void DataFlash_File::LogReadProcess(uint16_t log_num, ::lseek(_read_fd, start_page * DATAFLASH_PAGE_SIZE, SEEK_SET); } - _print_format_headers(num_types, structure, port); - while (true) { uint8_t data; if (::read(_read_fd, &data, 1) != 1) { diff --git a/libraries/DataFlash/LogFile.cpp b/libraries/DataFlash/LogFile.cpp index 34f4aac9ca..e35a6c204e 100644 --- a/libraries/DataFlash/LogFile.cpp +++ b/libraries/DataFlash/LogFile.cpp @@ -247,23 +247,6 @@ uint16_t DataFlash_Block::find_last_page_of_log(uint16_t log_number) #define PGM_UINT8(addr) pgm_read_byte((const prog_char *)addr) -/* - print the log column names - */ -void DataFlash_Class::_print_format_headers(uint8_t num_types, - const struct LogStructure *structure, - AP_HAL::BetterStream *port) -{ - uint8_t i; - for (i=0; iprintf_P(PSTR("LABL, %S, %u, %S, %S\n"), - structure[i].name, - (unsigned)PGM_UINT8(&structure[i].msg_type), - structure[i].format, - structure[i].labels); - } -} - /* read and print a log entry using the format strings from the given structure */ @@ -386,6 +369,14 @@ void DataFlash_Class::_print_log_entry(uint8_t msg_type, ofs += sizeof(v)-1; break; } + case 'Z': { + char v[65]; + memcpy(&v, &pkt[ofs], sizeof(v)); + v[sizeof(v)-1] = 0; + port->printf_P(PSTR("%s"), v); + ofs += sizeof(v)-1; + break; + } case 'M': { print_mode(port, pkt[ofs]); ofs += 1; @@ -419,8 +410,6 @@ void DataFlash_Block::LogReadProcess(uint16_t log_num, FinishWrite(); } - _print_format_headers(num_types, structure, port); - StartRead(start_page); while (true) { @@ -531,6 +520,8 @@ uint16_t DataFlash_Class::StartNewLog(uint8_t num_types, const struct LogStructu // write log formats so the log is self-describing for (uint8_t i=0; idelay(10); } // and all current parameters @@ -548,10 +539,12 @@ void DataFlash_Class::Log_Write_Format(const struct LogStructure *s) type : PGM_UINT8(&s->msg_type), length : PGM_UINT8(&s->msg_len), name : {}, - format : {} + format : {}, + labels : {} }; strncpy_P(pkt.name, s->name, sizeof(pkt.name)); strncpy_P(pkt.format, s->format, sizeof(pkt.format)); + strncpy_P(pkt.labels, s->labels, sizeof(pkt.labels)); WriteBlock(&pkt, sizeof(pkt)); }