aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io/controls.c
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-12-04 09:52:16 -0800
committerpx4dev <px4@purgatory.org>2012-12-04 09:52:16 -0800
commit7c3b28d503123121403b4ad68c934bb91b05d878 (patch)
tree44f090d7f31fc26fc91f04c60827ec6d68abb93c /apps/px4io/controls.c
parent1485a4ec1aa8328cc50d99a1195b20df2b11045e (diff)
downloadpx4-firmware-7c3b28d503123121403b4ad68c934bb91b05d878.tar.gz
px4-firmware-7c3b28d503123121403b4ad68c934bb91b05d878.tar.bz2
px4-firmware-7c3b28d503123121403b4ad68c934bb91b05d878.zip
Lock out the PPM decoder if the DSM or S.bus decoders have seen a frame recently.
Diffstat (limited to 'apps/px4io/controls.c')
-rw-r--r--apps/px4io/controls.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/apps/px4io/controls.c b/apps/px4io/controls.c
index 6cf3c80ac..3b3782918 100644
--- a/apps/px4io/controls.c
+++ b/apps/px4io/controls.c
@@ -86,15 +86,29 @@ controls_main(void)
* one control input source, they're going to fight each
* other. Don't do that.
*/
+ bool locked = false;
+
if (fds[0].revents & POLLIN)
- dsm_input();
+ locked |= dsm_input();
if (fds[1].revents & POLLIN)
- sbus_input();
- ppm_input();
+ locked |= sbus_input();
+
+ /*
+ * If we don't have lock from one of the serial receivers,
+ * look for PPM. It shares an input with S.bus, so there's
+ * a possibility it will mis-parse an S.bus frame.
+ *
+ * XXX each S.bus frame will cause a PPM decoder interrupt
+ * storm (lots of edges). It might be sensible to actually
+ * disable the PPM decoder completely if we have an alternate
+ * receiver lock.
+ */
+ if (!locked)
+ ppm_input();
/*
* If we haven't seen any new control data in 200ms, assume we
- * have lost input and tell FMU
+ * have lost input and tell FMU.
*/
if ((hrt_absolute_time() - system_state.rc_channels_timestamp) > 200000) {