Skip to content

Commit

Permalink
core: add info regarding missing parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Dec 12, 2024
1 parent 704c49f commit fd15b82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/mavsdk/core/mavlink_parameter_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ bool MavlinkParameterCache::exists(uint16_t param_index) const
return it != _all_params.end();
}

uint16_t MavlinkParameterCache::missing_count(uint16_t count) const
{
uint16_t missing = 0;

for (uint16_t i = 0; i < count; ++i) {
if (!exists(i)) {
++missing;
}
}

return missing;
}

std::optional<uint16_t> MavlinkParameterCache::next_missing_index(uint16_t count)
{
// Extended doesn't matter here because we use this function in the sender
Expand Down
3 changes: 3 additions & 0 deletions src/mavsdk/core/mavlink_parameter_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "param_value.h"

#include <cstdint>
#include <limits>
#include <map>
#include <string>
Expand Down Expand Up @@ -46,6 +47,8 @@ class MavlinkParameterCache {

[[nodiscard]] std::optional<uint16_t> next_missing_index(uint16_t count);

[[nodiscard]] uint16_t missing_count(uint16_t count) const;

void print_missing(uint16_t count);

void clear();
Expand Down
2 changes: 2 additions & 0 deletions src/mavsdk/core/mavlink_parameter_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,8 @@ void MavlinkParameterClient::process_param_value(const mavlink_message_t& messag
assert(false);
}

LogInfo() << "Requesting " << _param_cache.missing_count() << " parameters missed during initial burst.";

if (_parameter_debugging) {
LogDebug() << "Requesting missing parameter "
<< (int)maybe_next_missing_index.value();
Expand Down

0 comments on commit fd15b82

Please sign in to comment.