aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io/mixer.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-12-15 23:28:03 +0100
committerLorenz Meier <lm@inf.ethz.ch>2012-12-15 23:28:03 +0100
commitf81d00594c156c51ab976d3b6d101915377d7afa (patch)
tree041ff3b3d54ca5c2f7a995eadcbc2e58af1e56ba /apps/px4io/mixer.c
parent42ffb4161d4cec9e1d290d0191e7a4bb89546ed9 (diff)
downloadpx4-firmware-f81d00594c156c51ab976d3b6d101915377d7afa.tar.gz
px4-firmware-f81d00594c156c51ab976d3b6d101915377d7afa.tar.bz2
px4-firmware-f81d00594c156c51ab976d3b6d101915377d7afa.zip
Made PX4IO FMU timeout based on IOs HRT, updating mixers now on every FMU update and not at fixed rate, this is WIP and currently does not support mixing with RC-only
Diffstat (limited to 'apps/px4io/mixer.c')
-rw-r--r--apps/px4io/mixer.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/apps/px4io/mixer.c b/apps/px4io/mixer.c
index 5a644906b..318183ef5 100644
--- a/apps/px4io/mixer.c
+++ b/apps/px4io/mixer.c
@@ -53,10 +53,9 @@
#include "px4io.h"
/*
- * Count of periodic calls in which we have no FMU input.
+ * Maximum interval in us before FMU signal is considered lost
*/
-static unsigned fmu_input_drops;
-#define FMU_INPUT_DROP_LIMIT 20
+#define FMU_INPUT_DROP_LIMIT_US 200000
/*
* Update a mixer based on the current control signals.
@@ -91,17 +90,11 @@ mixer_tick(void)
control_values = &system_state.fmu_channel_data[0];
/* check that we are receiving fresh data from the FMU */
- if (!system_state.fmu_data_received) {
- fmu_input_drops++;
+ if ((hrt_absolute_time() - system_state.fmu_data_received_time) > FMU_INPUT_DROP_LIMIT_US) {
/* too many frames without FMU input, time to go to failsafe */
- if (fmu_input_drops >= FMU_INPUT_DROP_LIMIT) {
- system_state.mixer_manual_override = true;
- system_state.mixer_fmu_available = false;
- }
- } else {
- fmu_input_drops = 0;
- system_state.fmu_data_received = false;
+ system_state.mixer_manual_override = true;
+ system_state.mixer_fmu_available = false;
}
} else if (system_state.rc_channels > 0 && system_state.manual_override_ok) {
@@ -109,7 +102,7 @@ mixer_tick(void)
control_count = system_state.rc_channels;
control_values = &system_state.rc_channel_data[0];
} else {
- /* we have no control input */
+ /* we have no control input (no FMU, no RC) */
// XXX builtin failsafe would activate here
control_count = 0;