Plane: improve failsafe notifications

This commit is contained in:
Peter Barker 2017-09-22 13:31:44 +10:00 committed by Andrew Tridgell
parent 01d8c506d2
commit 7feef72b34
3 changed files with 13 additions and 5 deletions

View File

@ -901,6 +901,7 @@ private:
void failsafe_short_on_event(enum failsafe_state fstype, mode_reason_t reason);
void failsafe_long_on_event(enum failsafe_state fstype, mode_reason_t reason);
void failsafe_short_off_event(mode_reason_t reason);
void failsafe_long_off_event(mode_reason_t reason);
void low_battery_event(void);
void update_events(void);
uint8_t max_fencepoints(void);

View File

@ -5,7 +5,7 @@ void Plane::failsafe_short_on_event(enum failsafe_state fstype, mode_reason_t re
// This is how to handle a short loss of control signal failsafe.
failsafe.state = fstype;
failsafe.ch3_timer_ms = millis();
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Short event on, ");
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Short event on: type=%u/reason=%u", fstype, reason);
switch(control_mode)
{
case MANUAL:
@ -61,7 +61,7 @@ void Plane::failsafe_short_on_event(enum failsafe_state fstype, mode_reason_t re
void Plane::failsafe_long_on_event(enum failsafe_state fstype, mode_reason_t reason)
{
// This is how to handle a long loss of control signal failsafe.
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Long event on, ");
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Long event on: type=%u/reason=%u", fstype, reason);
// If the GCS is locked up we allow control to revert to RC
hal.rcin->clear_overrides();
failsafe.state = fstype;
@ -123,7 +123,7 @@ void Plane::failsafe_long_on_event(enum failsafe_state fstype, mode_reason_t rea
void Plane::failsafe_short_off_event(mode_reason_t reason)
{
// We're back in radio contact
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Short event off");
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Short event off: reason=%u", reason);
failsafe.state = FAILSAFE_NONE;
// re-read the switch so we can return to our preferred mode
@ -134,6 +134,13 @@ void Plane::failsafe_short_off_event(mode_reason_t reason)
}
}
void Plane::failsafe_long_off_event(mode_reason_t reason)
{
// We're back in radio contact
gcs().send_text(MAV_SEVERITY_WARNING, "Failsafe. Long event off: reason=%u", reason);
failsafe.state = FAILSAFE_NONE;
}
void Plane::low_battery_event(void)
{
if (failsafe.low_battery) {

View File

@ -509,10 +509,10 @@ void Plane::check_long_failsafe()
// We do not change state but allow for user to change mode
if (failsafe.state == FAILSAFE_GCS &&
(tnow - failsafe.last_heartbeat_ms) < timeout_seconds*1000) {
failsafe.state = FAILSAFE_NONE;
failsafe_long_off_event(MODE_REASON_GCS_FAILSAFE);
} else if (failsafe.state == FAILSAFE_LONG &&
!failsafe.ch3_failsafe) {
failsafe.state = FAILSAFE_NONE;
failsafe_long_off_event(MODE_REASON_RADIO_FAILSAFE);
}
}
}