From 7b46efaa6be6b4c795f88c2c185f3acd7cc523b9 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 28 Jul 2020 18:37:05 -0400 Subject: [PATCH] logger: record message gaps --- msg/logger_status.msg | 1 + src/modules/logger/logger.cpp | 15 ++++++++++++++- src/modules/logger/logger.h | 7 ++++--- src/modules/uORB/SubscriptionInterval.hpp | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/msg/logger_status.msg b/msg/logger_status.msg index 52721244ed..9a07871a0f 100644 --- a/msg/logger_status.msg +++ b/msg/logger_status.msg @@ -13,6 +13,7 @@ float32 total_written_kb # total written to log in kiloBytes float32 write_rate_kb_s # write rate in kiloBytes/s uint32 dropouts # number of failed buffer writes due to buffer overflow +uint32 message_gaps # messages misssed uint32 buffer_used_bytes # current buffer fill in Bytes uint32 buffer_size_bytes # total buffer size in Bytes diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index c2f7e66399..afe3b7b923 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -421,7 +421,19 @@ bool Logger::copy_if_updated(int sub_idx, void *buffer, bool try_to_subscribe) bool updated = false; if (sub.valid()) { - updated = sub.update(buffer); + if (sub.get_interval_us() == 0) { + // record gaps in full rate (no interval) messages + const unsigned last_generation = sub.get_last_generation(); + updated = sub.update(buffer); + + if (updated && (sub.get_last_generation() != last_generation + 1)) { + // error, missed a message + _message_gaps++; + } + + } else { + updated = sub.update(buffer); + } } else if (try_to_subscribe) { if (sub.subscribe()) { @@ -930,6 +942,7 @@ void Logger::publish_logger_status() status.total_written_kb = kb_written; status.write_rate_kb_s = kb_written / seconds; status.dropouts = _statistics[i].write_dropouts; + status.message_gaps = _message_gaps; status.buffer_used_bytes = buffer_fill_count_file; status.buffer_size_bytes = _writer.get_buffer_size_file(log_type); status.num_messages = _num_subscriptions; diff --git a/src/modules/logger/logger.h b/src/modules/logger/logger.h index 5d006875db..76536ffff2 100644 --- a/src/modules/logger/logger.h +++ b/src/modules/logger/logger.h @@ -68,14 +68,13 @@ namespace logger static constexpr uint8_t MSG_ID_INVALID = UINT8_MAX; struct LoggerSubscription : public uORB::SubscriptionInterval { - - uint8_t msg_id{MSG_ID_INVALID}; - LoggerSubscription() = default; LoggerSubscription(ORB_ID id, uint32_t interval_ms = 0, uint8_t instance = 0) : uORB::SubscriptionInterval(id, interval_ms * 1000, instance) {} + + uint8_t msg_id{MSG_ID_INVALID}; }; class Logger : public ModuleBase, public ModuleParams @@ -347,6 +346,8 @@ private: hrt_abstime _logger_status_last {0}; int _lockstep_component{-1}; + uint32_t _message_gaps{0}; + uORB::Subscription _manual_control_setpoint_sub{ORB_ID(manual_control_setpoint)}; uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)}; uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)}; diff --git a/src/modules/uORB/SubscriptionInterval.hpp b/src/modules/uORB/SubscriptionInterval.hpp index 6e944164a1..97222c8151 100644 --- a/src/modules/uORB/SubscriptionInterval.hpp +++ b/src/modules/uORB/SubscriptionInterval.hpp @@ -135,6 +135,7 @@ public: bool valid() const { return _subscription.valid(); } uint8_t get_instance() const { return _subscription.get_instance(); } + uint32_t get_interval_us() const { return _interval_us; } unsigned get_last_generation() const { return _subscription.get_last_generation(); } ORB_PRIO get_priority() { return _subscription.get_priority(); } orb_id_t get_topic() const { return _subscription.get_topic(); }