From 173edcef63b09fd0d334f57298368b0f24824cb8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 19 Nov 2015 16:33:56 +0100 Subject: [PATCH] Commander: Fix reporting in presence of no telemetry link --- src/modules/commander/commander.cpp | 4 ++-- src/modules/commander/state_machine_helper.cpp | 6 +++--- src/modules/commander/state_machine_helper.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 83e79b77fc..d416358eeb 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -382,9 +382,9 @@ int commander_main(int argc, char *argv[]) if (!strcmp(argv[1], "check")) { int mavlink_fd_local = px4_open(MAVLINK_LOG_DEVICE, 0); int checkres = 0; - checkres = preflight_check(&status, mavlink_fd_local, false); + checkres = preflight_check(&status, mavlink_fd_local, false, true); warnx("Preflight check: %s", (checkres == 0) ? "OK" : "FAILED"); - checkres = preflight_check(&status, mavlink_fd_local, true); + checkres = preflight_check(&status, mavlink_fd_local, true, true); warnx("Prearm check: %s", (checkres == 0) ? "OK" : "FAILED"); px4_close(mavlink_fd_local); return 0; diff --git a/src/modules/commander/state_machine_helper.cpp b/src/modules/commander/state_machine_helper.cpp index bcdb5d3f9d..295ea3dcd2 100644 --- a/src/modules/commander/state_machine_helper.cpp +++ b/src/modules/commander/state_machine_helper.cpp @@ -743,12 +743,12 @@ bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_en return status->nav_state != nav_state_old; } -int preflight_check(const struct vehicle_status_s *status, const int mavlink_fd, bool prearm) +int preflight_check(const struct vehicle_status_s *status, const int mavlink_fd, bool prearm, bool force_report) { /* */ - bool reportFailures = false; - reportFailures = !status->condition_system_prearm_error_reported && status->condition_system_hotplug_timeout; + bool reportFailures = force_report || (!status->data_link_lost && + !status->condition_system_prearm_error_reported && status->condition_system_hotplug_timeout); bool checkAirspeed = false; /* Perform airspeed check only if circuit breaker is not diff --git a/src/modules/commander/state_machine_helper.h b/src/modules/commander/state_machine_helper.h index bdb7b13f28..19b9394e3d 100644 --- a/src/modules/commander/state_machine_helper.h +++ b/src/modules/commander/state_machine_helper.h @@ -65,6 +65,6 @@ transition_result_t hil_state_transition(hil_state_t new_state, orb_advert_t sta bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_enabled, const bool mission_finished, const bool stay_in_failsafe); -int preflight_check(const struct vehicle_status_s *status, const int mavlink_fd, bool prearm); +int preflight_check(const struct vehicle_status_s *status, const int mavlink_fd, bool prearm, bool force_report=false); #endif /* STATE_MACHINE_HELPER_H_ */