Skip to content

Commit

Permalink
failsafe fixes
Browse files Browse the repository at this point in the history
breadoven committed Sep 7, 2023
1 parent eceabdb commit f1afdf8
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/main/flight/failsafe.c
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
13 changes: 7 additions & 6 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
@@ -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:
4 changes: 1 addition & 3 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
@@ -1806,8 +1806,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_FINIS
{
UNUSED(previousState);

disarm(DISARM_NAVIGATION);

return NAV_FSM_EVENT_NONE;
}

@@ -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()) {

0 comments on commit f1afdf8

Please sign in to comment.