mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 04:50:35 +08:00
HealthAndArmingChecks: add support for legacy mavlink_log reporting
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <uORB/topics/health_report.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_status_flags.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
@@ -195,6 +196,8 @@ public:
|
||||
|
||||
vehicle_status_flags_s &failsafeFlags() { return _status_flags; }
|
||||
|
||||
orb_advert_t *mavlink_log_pub() { return _mavlink_log_pub; }
|
||||
|
||||
/**
|
||||
* Whether arming is possible for a given navigation mode
|
||||
*/
|
||||
@@ -333,6 +336,8 @@ private:
|
||||
int _current_result{0};
|
||||
|
||||
vehicle_status_flags_s &_status_flags;
|
||||
|
||||
orb_advert_t *_mavlink_log_pub{nullptr}; ///< mavlink log publication for legacy reporting
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
|
||||
@@ -57,6 +57,26 @@ bool HealthAndArmingChecks::update(bool force_reporting)
|
||||
|
||||
if (_reporter.report(_context.isArmed(), force_reporting)) {
|
||||
|
||||
// LEGACY start
|
||||
// Run the checks again, this time with the mavlink publication set.
|
||||
// We don't expect any change, and rate limitation would prevent the events from being reported again,
|
||||
// so we only report mavlink_log_*.
|
||||
_reporter._mavlink_log_pub = &_mavlink_log_pub;
|
||||
_reporter.reset();
|
||||
|
||||
for (unsigned i = 0; i < sizeof(_checks) / sizeof(_checks[0]); ++i) {
|
||||
if (!_checks[i]) {
|
||||
break;
|
||||
}
|
||||
|
||||
_checks[i]->checkAndReport(_context, _reporter);
|
||||
}
|
||||
|
||||
_reporter.finalize();
|
||||
_reporter.report(_context.isArmed(), false);
|
||||
_reporter._mavlink_log_pub = nullptr;
|
||||
// LEGACY end
|
||||
|
||||
health_report_s health_report;
|
||||
_reporter.getHealthReport(health_report);
|
||||
health_report.timestamp = hrt_absolute_time();
|
||||
|
||||
@@ -63,6 +63,7 @@ protected:
|
||||
private:
|
||||
Context _context;
|
||||
Report _reporter;
|
||||
orb_advert_t _mavlink_log_pub{nullptr};
|
||||
|
||||
uORB::Publication<health_report_s> _health_report_pub{ORB_ID(health_report)};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user