From b515873bee9b95b3976e8893b51b003ed7d97f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 3 Jul 2017 17:54:53 +0200 Subject: [PATCH] ULog: add INFO_MULTIPLE & FLAG_BITS messages This requires support in the parsers, and thus the ULog file version is increased. As long as no data is appended, both, existing pyulog & FlightPlot, can still read the new logs (they will output a warning). The replay module will print an error, but still continue. --- src/modules/logger/logger.cpp | 12 +++++++++++- src/modules/logger/messages.h | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index 42aff41be4..abd4fb4d04 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -1639,10 +1639,20 @@ void Logger::write_header() header.magic[4] = 0x01; header.magic[5] = 0x12; header.magic[6] = 0x35; - header.magic[7] = 0x00; //file version 0 + header.magic[7] = 0x01; //file version 1 header.timestamp = hrt_absolute_time(); _writer.lock(); write_message(&header, sizeof(header)); + + // write the Flags message: this MUST be written right after the ulog header + ulog_message_flag_bits_s flag_bits; + + memset(&flag_bits, 0, sizeof(flag_bits)); + flag_bits.msg_size = sizeof(flag_bits) - ULOG_MSG_HEADER_LEN; + flag_bits.msg_type = static_cast(ULogMessageType::FLAG_BITS); + + write_message(&flag_bits, sizeof(flag_bits)); + _writer.unlock(); } diff --git a/src/modules/logger/messages.h b/src/modules/logger/messages.h index bcbe015730..78f9d78faf 100644 --- a/src/modules/logger/messages.h +++ b/src/modules/logger/messages.h @@ -37,12 +37,14 @@ enum class ULogMessageType : uint8_t { FORMAT = 'F', DATA = 'D', INFO = 'I', + INFO_MULTIPLE = 'M', PARAMETER = 'P', ADD_LOGGED_MSG = 'A', REMOVE_LOGGED_MSG = 'R', SYNC = 'S', DROPOUT = 'O', LOGGING = 'L', + FLAG_BITS = 'B', }; @@ -113,6 +115,15 @@ struct ulog_message_info_header_s { char key[255]; }; +struct ulog_message_info_multiple_header_s { + uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN + uint8_t msg_type = static_cast(ULogMessageType::INFO_MULTIPLE); + + uint8_t is_continued; ///< can be used for arrays: set to 1, if this message is part of the previous with the same key + uint8_t key_len; + char key[255]; +}; + struct ulog_message_logging_s { uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN uint8_t msg_type = static_cast(ULogMessageType::LOGGING); @@ -129,4 +140,17 @@ struct ulog_message_parameter_header_s { uint8_t key_len; char key[255]; }; + + +#define ULOG_INCOMPAT_FLAG0_DATA_APPENDED_MASK (1<<0) + +struct ulog_message_flag_bits_s { + uint16_t msg_size; + uint8_t msg_type = static_cast(ULogMessageType::FLAG_BITS); + + uint8_t compat_flags[8]; + uint8_t incompat_flags[8]; ///< @see ULOG_INCOMPAT_FLAG_* + uint64_t appended_offsets[3]; ///< file offset(s) for appended data if ULOG_INCOMPAT_FLAG0_DATA_APPENDED_MASK is set +}; + #pragma pack(pop)