mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-12 22:00:35 +08:00
mavlink log: ensure all critical & emergency msgs are also logged to console & ulog
Critical messages that the user sees should also go to the log file, so that the exact error (with time) can later be analyzed from the log file.
This commit is contained in:
@@ -623,7 +623,7 @@ transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub_local, co
|
||||
// For HIL platforms, require that simulated sensors are connected
|
||||
if (arm && hrt_absolute_time() > commander_boot_timestamp + INAIR_RESTART_HOLDOFF_INTERVAL &&
|
||||
is_hil_setup(autostart_id) && status.hil_state != vehicle_status_s::HIL_STATE_ON) {
|
||||
mavlink_and_console_log_critical(mavlink_log_pub_local, "HIL platform: Connect to simulator before arming");
|
||||
mavlink_log_critical(mavlink_log_pub_local, "HIL platform: Connect to simulator before arming");
|
||||
return TRANSITION_DENIED;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,7 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s
|
||||
cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED;
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "Takeoff denied, disarm and re-try");
|
||||
mavlink_log_critical(&mavlink_log_pub, "Takeoff denied, disarm and re-try");
|
||||
cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED;
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s
|
||||
cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED;
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "Landing denied, land manually.");
|
||||
mavlink_log_critical(&mavlink_log_pub, "Landing denied, land manually.");
|
||||
cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED;
|
||||
}
|
||||
|
||||
@@ -2110,30 +2110,30 @@ int commander_thread_main(int argc, char *argv[])
|
||||
critical_battery_voltage_actions_done = true;
|
||||
|
||||
if (!armed.armed) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "CRITICAL BATTERY, SHUT SYSTEM DOWN");
|
||||
mavlink_log_critical(&mavlink_log_pub, "CRITICAL BATTERY, SHUT SYSTEM DOWN");
|
||||
|
||||
} else {
|
||||
if (low_bat_action == 1) {
|
||||
// let us send the critical message even if already in RTL
|
||||
if (warning_action_on || TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state)) {
|
||||
warning_action_on = true;
|
||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RETURNING TO LAND");
|
||||
mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RETURNING TO LAND");
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RTL FAILED");
|
||||
mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RTL FAILED");
|
||||
}
|
||||
|
||||
} else if (low_bat_action == 2) {
|
||||
if (warning_action_on || TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LAND, main_state_prev, &status_flags, &internal_state)) {
|
||||
warning_action_on = true;
|
||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING AT CURRENT POSITION");
|
||||
mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING AT CURRENT POSITION");
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING FAILED");
|
||||
mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING FAILED");
|
||||
}
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING ADVISED!");
|
||||
mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING ADVISED!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2381,12 +2381,12 @@ int commander_thread_main(int argc, char *argv[])
|
||||
static bool flight_termination_printed = false;
|
||||
|
||||
if (!flight_termination_printed) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "Geofence violation: flight termination");
|
||||
mavlink_log_critical(&mavlink_log_pub, "Geofence violation: flight termination");
|
||||
flight_termination_printed = true;
|
||||
}
|
||||
|
||||
if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "Flight termination active");
|
||||
mavlink_log_critical(&mavlink_log_pub, "Flight termination active");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2636,7 +2636,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
} else {
|
||||
if (!status.data_link_lost) {
|
||||
if (armed.armed) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "ALL DATA LINKS LOST");
|
||||
mavlink_log_critical(&mavlink_log_pub, "ALL DATA LINKS LOST");
|
||||
}
|
||||
status.data_link_lost = true;
|
||||
status.data_link_lost_counter++;
|
||||
@@ -2726,7 +2726,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
static bool flight_termination_printed = false;
|
||||
|
||||
if (!flight_termination_printed) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "DL and GPS lost: flight termination");
|
||||
mavlink_log_critical(&mavlink_log_pub, "DL and GPS lost: flight termination");
|
||||
flight_termination_printed = true;
|
||||
}
|
||||
|
||||
@@ -3716,7 +3716,7 @@ void *commander_low_prio_loop(void *arg)
|
||||
int ret = param_save_default();
|
||||
|
||||
if (ret != OK) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "settings auto save error");
|
||||
mavlink_log_critical(&mavlink_log_pub, "settings auto save error");
|
||||
} else {
|
||||
PX4_DEBUG("commander: settings saved.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user