diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-16 16:30:41 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-16 16:30:41 +0100 |
commit | b9606d0d6ea1f0a87e408527a5838210dcbb931b (patch) | |
tree | cc0a3ceb669f1084d3143e43cb3706bd182c04ab /apps/px4io/safety.c | |
parent | e56911bf2d637682f64fe93add114f8fef2682fd (diff) | |
download | px4-firmware-b9606d0d6ea1f0a87e408527a5838210dcbb931b.tar.gz px4-firmware-b9606d0d6ea1f0a87e408527a5838210dcbb931b.tar.bz2 px4-firmware-b9606d0d6ea1f0a87e408527a5838210dcbb931b.zip |
Reverted arming state machine back to its original state, operational again
Diffstat (limited to 'apps/px4io/safety.c')
-rw-r--r-- | apps/px4io/safety.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/apps/px4io/safety.c b/apps/px4io/safety.c index 9ce4589b7..780a4331a 100644 --- a/apps/px4io/safety.c +++ b/apps/px4io/safety.c @@ -71,8 +71,14 @@ static unsigned counter = 0; static unsigned blink_counter = 0; +/* + * IMPORTANT: The arming state machine critically + * depends on using the same threshold + * for arming and disarming. Since disarming + * is quite deadly for the system, a similar + * length can be justified. + */ #define ARM_COUNTER_THRESHOLD 10 -#define DISARM_COUNTER_THRESHOLD 4 static bool safety_button_pressed; @@ -102,8 +108,16 @@ safety_check_button(void *arg) */ safety_button_pressed = BUTTON_SAFETY; - /* Keep pressed for a while to arm */ + /* + * Keep pressed for a while to arm. + * + * Note that the counting sequence has to be same length + * for arming / disarming in order to end up as proper + * state machine, keep ARM_COUNTER_THRESHOLD the same + * length in all cases of the if/else struct below. + */ if (safety_button_pressed && !system_state.armed) { + if (counter < ARM_COUNTER_THRESHOLD) { counter++; } else if (counter == ARM_COUNTER_THRESHOLD) { @@ -114,9 +128,10 @@ safety_check_button(void *arg) } /* Disarm quickly */ } else if (safety_button_pressed && system_state.armed) { - if (counter < DISARM_COUNTER_THRESHOLD) { + + if (counter < ARM_COUNTER_THRESHOLD) { counter++; - } else if (counter == DISARM_COUNTER_THRESHOLD) { + } else if (counter == ARM_COUNTER_THRESHOLD) { /* change to disarmed state and notify the FMU */ system_state.armed = false; counter++; |