Skip to content
18 changes: 9 additions & 9 deletions docs/plugins/px4_events/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@
{
"name": "event_decoding_mode",
"type_name": "string",
"line": 59,
"line": 60,
"default_value": "\"auto\"",
"description": "PX4 event logging: auto (default), local, or disabled; changes require restart."
},
{
"name": "event_metadata_file",
"type_name": "string",
"line": 62,
"line": 63,
"default_value": "\"\"",
"description": "Firmware-matching local JSON or JSON.xz definitions; valid only in local mode."
},
{
"name": "event_metadata_download_delay",
"type_name": "double",
"line": 65,
"line": 66,
"default_value": "30.0",
"description": "Automatic metadata download delay from FCU connection, in seconds."
},
{
"name": "event_metadata_cache_enabled",
"type_name": "bool",
"line": 68,
"line": 69,
"default_value": "true",
"description": "Reuse validated persistent definitions in automatic mode."
},
{
"name": "event_metadata_cache_dir",
"type_name": "string",
"line": 71,
"line": 72,
"default_value": "\"\"",
"description": "Empty selects $HOME/.cache/mavros/px4_events; otherwise use this directory."
},
{
"name": "event_metadata_cache_max_bytes",
"type_name": "integer",
"line": 74,
"line": 75,
"default_value": "MetadataCache::DEFAULT_MAX_BYTES",
"description": "Best-effort finalized cache size limit; nonpositive values disable persistence."
}
Expand All @@ -61,7 +61,7 @@
"message_name": "EVENT",
"msg_id_expr": "mavlink::common::msg::EVENT::MSG_ID",
"dialect": "common",
"line": 312,
"line": 335,
"msg_id": 410
},
{
Expand All @@ -70,7 +70,7 @@
"message_name": "COMPONENT_METADATA",
"msg_id_expr": "mavlink::common::msg::COMPONENT_METADATA::MSG_ID",
"dialect": "common",
"line": 282,
"line": 305,
"msg_id": 397
},
{
Expand All @@ -79,7 +79,7 @@
"message_name": "COMPONENT_INFORMATION",
"msg_id_expr": "mavlink::common::msg::COMPONENT_INFORMATION::MSG_ID",
"dialect": "common",
"line": 296,
"line": 319,
"msg_id": 395
}
],
Expand Down
43 changes: 33 additions & 10 deletions mavros_px4_events/src/plugins/px4_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cmath>
#include <cstdint>
#include <exception>
#include <map>
#include <memory>
#include <mutex>
#include <string>
Expand Down Expand Up @@ -84,6 +85,8 @@ class PX4EventsPlugin : public plugin::Plugin
event_decoder.reset();
RCLCPP_ERROR(get_logger(),
"PX4 event decoding inactive: %s; retaining core raw event logging", error.c_str());
} else {
log_skipped_definitions(event_decoder->take_skipped_definitions());
}
if (mode == "auto" && error.empty()) {
event_download_delay = download_delay;
Expand Down Expand Up @@ -152,21 +155,41 @@ class PX4EventsPlugin : public plugin::Plugin
};
}

void event_acquisition_complete(uint64_t generation, Acquisition::Result result)
void log_skipped_definitions(const std::map<uint32_t, std::string> & skipped) const
{
std::lock_guard<std::recursive_mutex> lock(event_mutex);
if (generation != event_generation || !event_connected ||
!uas->is_connected() || !uas->is_px4())
{
if (skipped.empty()) {
return;
}
if (event_start_timer) {
event_start_timer->cancel();
RCLCPP_WARN(get_logger(),
"Skipped %zu PX4 event definitions; "
"retaining core raw logging for those events. "
"Enable mavros.px4_events DEBUG logging for details.", skipped.size());
for (const auto & [id, reason] : skipped) {
RCLCPP_DEBUG(get_logger(), "Skipped PX4 event definition ID %u: %s",
static_cast<unsigned int>(id), reason.c_str());
}
if (!result.decoder) {
return;
}

void event_acquisition_complete(uint64_t generation, Acquisition::Result result)
{
std::map<uint32_t, std::string> skipped;
{
std::lock_guard<std::recursive_mutex> lock(event_mutex);
if (generation != event_generation || !event_connected ||
!uas->is_connected() || !uas->is_px4())
{
return;
}
if (event_start_timer) {
event_start_timer->cancel();
}
if (!result.decoder) {
return;
}
skipped = result.decoder->take_skipped_definitions();
event_decoder = std::shared_ptr<Decoder>(std::move(result.decoder));
}
event_decoder = std::shared_ptr<Decoder>(std::move(result.decoder));
log_skipped_definitions(skipped);
RCLCPP_INFO(get_logger(), "PX4 event metadata ready; decoded logging enabled");
}

Expand Down
Loading
Loading