From eefdc32f5120f2b4ef2141526699e96e126e9f7b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 11 Mar 2016 09:13:28 +1100 Subject: [PATCH] Replay: print message when gap perceived in log --- Tools/Replay/LR_MsgHandler.cpp | 8 ++++++++ Tools/Replay/LR_MsgHandler.h | 12 ++++++++++++ Tools/Replay/LogReader.cpp | 3 +++ Tools/Replay/Replay.cpp | 11 +++++++++++ 4 files changed, 34 insertions(+) diff --git a/Tools/Replay/LR_MsgHandler.cpp b/Tools/Replay/LR_MsgHandler.cpp index d9acefb18a..3fb24fb4ab 100644 --- a/Tools/Replay/LR_MsgHandler.cpp +++ b/Tools/Replay/LR_MsgHandler.cpp @@ -445,6 +445,14 @@ void LR_MsgHandler_PARM::process_message(uint8_t *msg) } } +void LR_MsgHandler_PM::process_message(uint8_t *msg) +{ + uint32_t new_logdrop; + if (field_value(msg, "LogDrop", new_logdrop) && + new_logdrop != 0) { + printf("PM.LogDrop: %u dropped at timestamp %lu\n", new_logdrop, last_timestamp_usec); + } +} void LR_MsgHandler_SIM::process_message(uint8_t *msg) { diff --git a/Tools/Replay/LR_MsgHandler.h b/Tools/Replay/LR_MsgHandler.h index b192b14f7d..64d7e3d390 100644 --- a/Tools/Replay/LR_MsgHandler.h +++ b/Tools/Replay/LR_MsgHandler.h @@ -435,6 +435,18 @@ public: virtual void process_message(uint8_t *msg); }; +class LR_MsgHandler_PM : public LR_MsgHandler +{ +public: + LR_MsgHandler_PM(log_Format &_f, DataFlash_Class &_dataflash, + uint64_t &_last_timestamp_usec) + : LR_MsgHandler(_f, _dataflash, _last_timestamp_usec) { }; + + virtual void process_message(uint8_t *msg); + +private: + +}; class LR_MsgHandler_SIM : public LR_MsgHandler { diff --git a/Tools/Replay/LogReader.cpp b/Tools/Replay/LogReader.cpp index 0485e7d670..3918df0a6c 100644 --- a/Tools/Replay/LogReader.cpp +++ b/Tools/Replay/LogReader.cpp @@ -266,6 +266,9 @@ bool LogReader::handle_log_format_msg(const struct log_Format &f) msgparser[f.type] = new LR_MsgHandler_CHEK(formats[f.type], dataflash, last_timestamp_usec, check_state); + } else if (streq(name, "PM")) { + msgparser[f.type] = new LR_MsgHandler_PM(formats[f.type], dataflash, + last_timestamp_usec); } else { debug(" No parser for (%s)\n", name); } diff --git a/Tools/Replay/Replay.cpp b/Tools/Replay/Replay.cpp index 50022a5c80..70c373bd19 100644 --- a/Tools/Replay/Replay.cpp +++ b/Tools/Replay/Replay.cpp @@ -765,6 +765,7 @@ void Replay::log_check_solution(void) void Replay::loop() { + uint64_t last_timestamp = 0; while (true) { char type[5]; @@ -780,6 +781,16 @@ void Replay::loop() fclose(plotf); break; } + + if (last_timestamp != 0) { + uint64_t gap = AP_HAL::micros64() - last_timestamp; + if (gap > 40000) { + ::printf("Gap in log at timestamp=%lu of length %luus\n", + last_timestamp, gap); + } + } + last_timestamp = AP_HAL::micros64(); + read_sensors(type); if (streq(type,"ATT")) {