Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failsafe fixes #9283

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/flight/failsafe.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ static const failsafeProcedureLogic_t failsafeProcedureLogic[] = {
*/
void failsafeReset(void)
{
if (failsafeState.active) { // can't reset if still active
return;
}

failsafeState.rxDataFailurePeriod = PERIOD_RXDATA_FAILURE + failsafeConfig()->failsafe_delay * MILLIS_PER_TENTH_SECOND;
failsafeState.rxDataRecoveryPeriod = PERIOD_RXDATA_RECOVERY + failsafeConfig()->failsafe_recovery_delay * MILLIS_PER_TENTH_SECOND;
failsafeState.validRxDataReceivedAt = 0;
Expand All @@ -157,6 +161,7 @@ void failsafeReset(void)
failsafeState.phase = FAILSAFE_IDLE;
failsafeState.rxLinkState = FAILSAFE_RXLINK_DOWN;
failsafeState.activeProcedure = failsafeConfig()->failsafe_procedure;
failsafeState.controlling = false;

failsafeState.lastGoodRcCommand[ROLL] = 0;
failsafeState.lastGoodRcCommand[PITCH] = 0;
Expand Down
13 changes: 7 additions & 6 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,14 @@ static const char * osdArmingDisabledReasonMessage(void)
// See handling of FAILSAFE_RX_LOSS_MONITORING in failsafe.c
if (failsafePhase() == FAILSAFE_RX_LOSS_MONITORING) {
if (failsafeIsReceivingRxData()) {
// If we're not using sticks, it means the ARM switch
// hasn't been off since entering FAILSAFE_RX_LOSS_MONITORING
// yet
return OSD_MESSAGE_STR(OSD_MSG_TURN_ARM_SW_OFF);
// reminder to disarm to exit FAILSAFE_RX_LOSS_MONITORING once timeout period ends
if (IS_RC_MODE_ACTIVE(BOXARM)) {
return OSD_MESSAGE_STR(OSD_MSG_TURN_ARM_SW_OFF);
}
} else {
// Not receiving RX data
return OSD_MESSAGE_STR(OSD_MSG_RC_RX_LINK_LOST);
}
// Not receiving RX data
return OSD_MESSAGE_STR(OSD_MSG_RC_RX_LINK_LOST);
}
return OSD_MESSAGE_STR(OSD_MSG_DISABLED_BY_FS);
case ARMING_DISABLED_NOT_LEVEL:
Expand Down
4 changes: 1 addition & 3 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,8 +1806,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_FINIS
{
UNUSED(previousState);

disarm(DISARM_NAVIGATION);

return NAV_FSM_EVENT_NONE;
}

Expand Down Expand Up @@ -2840,7 +2838,7 @@ void updateLandingStatus(timeMs_t currentTimeMs)
}
} else if (STATE(LANDING_DETECTED)) {
pidResetErrorAccumulators();
if (navConfig()->general.flags.disarm_on_landing) {
if (navConfig()->general.flags.disarm_on_landing && !FLIGHT_MODE(FAILSAFE_MODE)) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED);
disarm(DISARM_LANDING);
} else if (!navigationInAutomaticThrottleMode()) {
Expand Down