Skip to content
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
4 changes: 2 additions & 2 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,9 @@ Defines debug values exposed in debug variables (developer / debugging setting)

---

### disarm_kill_switch
### disarm_always

Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low. Only applies when arming and disarming with an AUX channel.
Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low.

| Default | Min | Max |
| --- | --- | --- |
Expand Down
1 change: 0 additions & 1 deletion docs/development/Blackbox Internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ The log end marker is an optional Event ("E") frame of type 0xFF whose payload i
<li> Sticks</li>
<li> Switch_3D</li>
<li> Switch</li>
<li> Killswitch</li>
<li> Failsafe</li>
<li> Navigation</li>
</ol>
Expand Down
10 changes: 1 addition & 9 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,6 @@ static void updateArmingStatus(void)
DISABLE_ARMING_FLAG(ARMING_DISABLED_BOXFAILSAFE);
}

/* CHECK: BOXKILLSWITCH */
if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_BOXKILLSWITCH);
}
else {
DISABLE_ARMING_FLAG(ARMING_DISABLED_BOXKILLSWITCH);
}

/* CHECK: Do not allow arming if Servo AutoTrim is enabled */
if (IS_RC_MODE_ACTIVE(BOXAUTOTRIM)) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_SERVO_AUTOTRIM);
Expand Down Expand Up @@ -525,7 +517,7 @@ bool emergInflightRearmEnabled(void)
timeMs_t currentTimeMs = millis();
emergRearmStabiliseTimeout = 0;

if ((lastDisarmReason != DISARM_SWITCH && lastDisarmReason != DISARM_KILLSWITCH) ||
if ((lastDisarmReason != DISARM_SWITCH) ||
(currentTimeMs > US2MS(lastDisarmTimeUs) + EMERGENCY_INFLIGHT_REARM_TIME_WINDOW_MS)) {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/fc/fc_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ typedef enum disarmReason_e {
DISARM_STICKS = 2,
DISARM_SWITCH_3D = 3,
DISARM_SWITCH = 4,
DISARM_KILLSWITCH = 5,
DISARM_FAILSAFE = 6,
DISARM_NAVIGATION = 7,
DISARM_LANDING = 8,
Expand Down
13 changes: 0 additions & 13 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU16(dst, getRSSI());
break;

case MSP_ARMING_CONFIG:
sbufWriteU8(dst, 0);
sbufWriteU8(dst, armingConfig()->disarm_kill_switch);
break;

case MSP_LOOP_TIME:
sbufWriteU16(dst, gyroConfig()->looptime);
break;
Expand Down Expand Up @@ -1828,14 +1823,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break;
#endif

case MSP_SET_ARMING_CONFIG:
if (dataSize == 2) {
sbufReadU8(src); //Swallow the first byte, used to be auto_disarm_delay
armingConfigMutable()->disarm_kill_switch = !!sbufReadU8(src);
} else
return MSP_RESULT_ERROR;
break;

case MSP_SET_LOOP_TIME:
if (sbufReadU16Safe(&tmp_u16, src))
gyroConfigMutable()->looptime = tmp_u16;
Expand Down
3 changes: 0 additions & 3 deletions src/main/fc/fc_msp_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = {
{ .boxId = BOXTURNASSIST, .boxName = "TURN ASSIST", .permanentId = 35 },
{ .boxId = BOXNAVLAUNCH, .boxName = "NAV LAUNCH", .permanentId = 36 },
{ .boxId = BOXAUTOTRIM, .boxName = "SERVO AUTOTRIM", .permanentId = 37 },
{ .boxId = BOXKILLSWITCH, .boxName = "KILLSWITCH", .permanentId = 38 },
{ .boxId = BOXCAMERA1, .boxName = "CAMERA CONTROL 1", .permanentId = 39 },
{ .boxId = BOXCAMERA2, .boxName = "CAMERA CONTROL 2", .permanentId = 40 },
{ .boxId = BOXCAMERA3, .boxName = "CAMERA CONTROL 3", .permanentId = 41 },
Expand Down Expand Up @@ -320,7 +319,6 @@ void initActiveBoxIds(void)
}
#endif

ADD_ACTIVE_BOX(BOXKILLSWITCH);
ADD_ACTIVE_BOX(BOXFAILSAFE);

#if defined(USE_RCDEVICE) || defined(USE_MSP_DISPLAYPORT)
Expand Down Expand Up @@ -405,7 +403,6 @@ void packBoxModeFlags(boxBitmask_t * mspBoxModeFlags)
CHECK_ACTIVE_BOX(IS_ENABLED(FLIGHT_MODE(NAV_LAUNCH_MODE)), BOXNAVLAUNCH);
CHECK_ACTIVE_BOX(IS_ENABLED(FLIGHT_MODE(AUTO_TUNE)), BOXAUTOTUNE);
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXAUTOTRIM)), BOXAUTOTRIM);
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXKILLSWITCH)), BOXKILLSWITCH);
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXHOMERESET)), BOXHOMERESET);
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCAMERA1)), BOXCAMERA1);
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCAMERA2)), BOXCAMERA2);
Expand Down
11 changes: 3 additions & 8 deletions src/main/fc/rc_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ PG_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig,
.airmodeThrottleThreshold = SETTING_AIRMODE_THROTTLE_THRESHOLD_DEFAULT,
);

PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 2);
PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 3);

PG_RESET_TEMPLATE(armingConfig_t, armingConfig,
.fixed_wing_auto_arm = SETTING_FIXED_WING_AUTO_ARM_DEFAULT,
.disarm_kill_switch = SETTING_DISARM_KILL_SWITCH_DEFAULT,
.disarm_always = SETTING_DISARM_ALWAYS_DEFAULT,
.switchDisarmDelayMs = SETTING_SWITCH_DISARM_DELAY_DEFAULT,
.prearmTimeoutMs = SETTING_PREARM_TIMEOUT_DEFAULT,
);
Expand Down Expand Up @@ -231,7 +231,7 @@ void processRcStickPositions(bool isThrottleLow)
if (ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXFAILSAFE) && rxIsReceivingSignal() && !failsafeIsActive()) {
const timeMs_t disarmDelay = currentTimeMs - rcDisarmTimeMs;
if (disarmDelay > armingConfig()->switchDisarmDelayMs) {
if (armingConfig()->disarm_kill_switch || isThrottleLow) {
if (armingConfig()->disarm_always || isThrottleLow) {
disarm(DISARM_SWITCH);
}
}
Expand All @@ -240,11 +240,6 @@ void processRcStickPositions(bool isThrottleLow)
rcDisarmTimeMs = currentTimeMs;
}
}

// KILLSWITCH disarms instantly
if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) {
disarm(DISARM_KILLSWITCH);
}
}

if (rcDelayCommand != 20) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/rc_controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ PG_DECLARE(rcControlsConfig_t, rcControlsConfig);

typedef struct armingConfig_s {
bool fixed_wing_auto_arm; // Auto-arm fixed wing aircraft on throttle up and never disarm
bool disarm_kill_switch; // allow disarm via AUX switch regardless of throttle value
bool disarm_always; // Disarm motors regardless of throttle value
uint16_t switchDisarmDelayMs; // additional delay between ARM box going off and actual disarm
uint16_t prearmTimeoutMs; // duration for which Prearm being activated is valid. after this, Prearm needs to be reset. 0 means Prearm does not timeout.
} armingConfig_t;
Expand Down
1 change: 0 additions & 1 deletion src/main/fc/rc_modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ typedef enum {
BOXAIRMODE = 20,
BOXHOMERESET = 21,
BOXGCSNAV = 22,
BOXKILLSWITCH = 23, // old HEADING LOCK
BOXSURFACE = 24,
BOXFLAPERON = 25,
BOXTURNASSIST = 26,
Expand Down
3 changes: 1 addition & 2 deletions src/main/fc/runtime_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static EXTENDED_FASTRAM uint32_t enabledSensors = 0;
#if !defined(CLI_MINIMAL_VERBOSITY)
const char *armingDisableFlagNames[]= {
"FS", "ANGLE", "CAL", "OVRLD", "NAV", "COMPASS",
"ACC", "ARMSW", "HWFAIL", "BOXFS", "KILLSW", "RX",
"ACC", "ARMSW", "HWFAIL", "BOXFS", "RX",
"THR", "CLI", "CMS", "OSD", "ROLL/PITCH", "AUTOTRIM", "OOM",
"SETTINGFAIL", "PWMOUT", "NOPREARM", "DSHOTBEEPER", "LANDED"
};
Expand All @@ -50,7 +50,6 @@ const armingFlag_e armDisableReasonsChecklist[] = {
ARMING_DISABLED_NAVIGATION_UNSAFE,
ARMING_DISABLED_ARM_SWITCH,
ARMING_DISABLED_BOXFAILSAFE,
ARMING_DISABLED_BOXKILLSWITCH,
ARMING_DISABLED_THROTTLE,
ARMING_DISABLED_CLI,
ARMING_DISABLED_CMS_MENU,
Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/runtime_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef enum {
ARMING_DISABLED_ARM_SWITCH = (1 << 14),
ARMING_DISABLED_HARDWARE_FAILURE = (1 << 15),
ARMING_DISABLED_BOXFAILSAFE = (1 << 16),
ARMING_DISABLED_BOXKILLSWITCH = (1 << 17),

ARMING_DISABLED_RC_LINK = (1 << 18),
ARMING_DISABLED_THROTTLE = (1 << 19),
ARMING_DISABLED_CLI = (1 << 20),
Expand All @@ -53,7 +53,7 @@ typedef enum {
ARMING_DISABLED_SYSTEM_OVERLOADED | ARMING_DISABLED_NAVIGATION_UNSAFE |
ARMING_DISABLED_COMPASS_NOT_CALIBRATED | ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED |
ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_HARDWARE_FAILURE | ARMING_DISABLED_BOXFAILSAFE |
ARMING_DISABLED_BOXKILLSWITCH | ARMING_DISABLED_RC_LINK | ARMING_DISABLED_THROTTLE | ARMING_DISABLED_CLI |
ARMING_DISABLED_RC_LINK | ARMING_DISABLED_THROTTLE | ARMING_DISABLED_CLI |
ARMING_DISABLED_CMS_MENU | ARMING_DISABLED_OSD_MENU | ARMING_DISABLED_ROLLPITCH_NOT_CENTERED |
ARMING_DISABLED_SERVO_AUTOTRIM | ARMING_DISABLED_OOM | ARMING_DISABLED_INVALID_SETTING |
ARMING_DISABLED_PWM_OUTPUT_ERROR | ARMING_DISABLED_NO_PREARM | ARMING_DISABLED_DSHOT_BEEPER |
Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1496,8 +1496,8 @@ groups:
description: "Auto-arm fixed wing aircraft on throttle above min_check, and disarming with stick commands are disabled, so power cycle is required to disarm. Requires enabled motorstop and no arm switch configured."
default_value: OFF
type: bool
- name: disarm_kill_switch
description: "Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low. Only applies when arming and disarming with an AUX channel."
- name: disarm_always
description: "Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low."
default_value: ON
type: bool
- name: switch_disarm_delay
Expand Down
5 changes: 2 additions & 3 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,6 @@ static const char * osdArmingDisabledReasonMessage(void)
return OSD_MESSAGE_STR(OSD_MSG_HW_FAIL);
case ARMING_DISABLED_BOXFAILSAFE:
return OSD_MESSAGE_STR(OSD_MSG_FS_EN);
case ARMING_DISABLED_BOXKILLSWITCH:
return OSD_MESSAGE_STR(OSD_MSG_KILL_SW_EN);
case ARMING_DISABLED_RC_LINK:
return OSD_MESSAGE_STR(OSD_MSG_NO_RC_LINK);
case ARMING_DISABLED_THROTTLE:
Expand Down Expand Up @@ -4424,7 +4422,8 @@ static void osdUpdateStats(void)

static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
{
const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"};
//We keep "" for backward compatibility with the Blackbox explorer and other potential usages
const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "", "FAILSAFE", "NAV SYS", "LANDING"};
uint8_t top = 1; // Start one line down leaving space at the top of the screen.
size_t multiValueLengthOffset = 0;

Expand Down
1 change: 0 additions & 1 deletion src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#define OSD_MSG_PITOT_FAIL "PITOT METER FAILURE"
#define OSD_MSG_HW_FAIL "HARDWARE FAILURE"
#define OSD_MSG_FS_EN "FAILSAFE MODE ENABLED"
#define OSD_MSG_KILL_SW_EN "KILLSWITCH MODE ENABLED"
#define OSD_MSG_NO_RC_LINK "NO RC LINK"
#define OSD_MSG_THROTTLE_NOT_LOW "THROTTLE IS NOT LOW"
#define OSD_MSG_ROLLPITCH_OFFCENTER "ROLLPITCH NOT CENTERED"
Expand Down
2 changes: 0 additions & 2 deletions src/main/io/osd_dji_hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ static char * osdArmingDisabledReasonMessage(void)
// return OSD_MESSAGE_STR("HARDWARE FAILURE");
case ARMING_DISABLED_BOXFAILSAFE:
return OSD_MESSAGE_STR("FAILSAFE ENABLED");
case ARMING_DISABLED_BOXKILLSWITCH:
return OSD_MESSAGE_STR("KILLSWITCH ENABLED");
case ARMING_DISABLED_RC_LINK:
return OSD_MESSAGE_STR("NO RC LINK");
case ARMING_DISABLED_THROTTLE:
Expand Down
3 changes: 0 additions & 3 deletions src/main/msp/msp_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@

#define MSP_SONAR_ALTITUDE 58 //out message get surface altitude [cm]

#define MSP_ARMING_CONFIG 61 //out message Returns auto_disarm_delay and disarm_kill_switch parameters
#define MSP_SET_ARMING_CONFIG 62 //in message Sets auto_disarm_delay and disarm_kill_switch parameters

//
// Baseflight MSP commands (if enabled they exist in Cleanflight)
//
Expand Down
56 changes: 0 additions & 56 deletions src/test/unit/flight_failsafe_unittest.cc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,62 +297,6 @@ TEST(FlightFailsafeTest, TestFailsafeDetectsRxLossAndJustDisarms)
EXPECT_FALSE(ARMING_FLAG(PREVENT_ARMING));
}

/****************************************************************************************/
TEST(FlightFailsafeTest, TestFailsafeDetectsKillswitchEvent)
{
// given
ENABLE_ARMING_FLAG(ARMED);
resetCallCounters();
failsafeStartMonitoring();

// and
throttleStatus = THROTTLE_HIGH; // throttle HIGH to go for a failsafe landing procedure
failsafeConfig.failsafe_kill_switch = 1; // configure AUX switch as kill switch
ACTIVATE_RC_MODE(BOXFAILSAFE); // and activate it
sysTickUptime = 0; // restart time from 0
failsafeOnValidDataReceived(); // set last valid sample at current time
sysTickUptime = PERIOD_RXDATA_FAILURE + 1; // adjust time to point just past the failure time to
failsafeOnValidDataFailed(); // cause a lost link

// when
failsafeUpdateState(); // kill switch handling should come first

// then
EXPECT_EQ(true, failsafeIsActive());
EXPECT_TRUE(ARMING_FLAG(PREVENT_ARMING));
EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM));
EXPECT_EQ(FAILSAFE_RX_LOSS_MONITORING, failsafePhase());

// given
failsafeOnValidDataFailed(); // set last invalid sample at current time
sysTickUptime += PERIOD_RXDATA_RECOVERY + 1; // adjust time to point just past the recovery time to
failsafeOnValidDataReceived(); // cause a recovered link

rcModeActivationMask = DE_ACTIVATE_ALL_BOXES; // BOXFAILSAFE must be off (kill switch)

// when
failsafeUpdateState();

// then
EXPECT_EQ(true, failsafeIsActive());
EXPECT_TRUE(ARMING_FLAG(PREVENT_ARMING));
EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM));
EXPECT_EQ(FAILSAFE_RX_LOSS_MONITORING, failsafePhase());

// given
sysTickUptime += PERIOD_OF_1_SECONDS + 1; // adjust time to point just past the required additional recovery time
failsafeOnValidDataReceived();

// when
failsafeUpdateState();

// then
EXPECT_EQ(false, failsafeIsActive());
EXPECT_EQ(FAILSAFE_IDLE, failsafePhase());
EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM)); // disarm not called repeatedly.
EXPECT_FALSE(ARMING_FLAG(PREVENT_ARMING));
}

/****************************************************************************************/
//
// Additional non-stepwise tests
Expand Down