logger: record message gaps

This commit is contained in:
Daniel Agar 2020-07-28 18:37:05 -04:00
parent f7415c3354
commit 7b46efaa6b
4 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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<Logger>, 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)};

View File

@ -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(); }