diff options
author | px4dev <px4@purgatory.org> | 2012-12-04 09:52:16 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-12-04 09:52:16 -0800 |
commit | 7c3b28d503123121403b4ad68c934bb91b05d878 (patch) | |
tree | 44f090d7f31fc26fc91f04c60827ec6d68abb93c /apps/px4io/dsm.c | |
parent | 1485a4ec1aa8328cc50d99a1195b20df2b11045e (diff) | |
download | px4-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/dsm.c')
-rw-r--r-- | apps/px4io/dsm.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/px4io/dsm.c b/apps/px4io/dsm.c index 5841f29a3..04aca709b 100644 --- a/apps/px4io/dsm.c +++ b/apps/px4io/dsm.c @@ -104,7 +104,7 @@ dsm_init(const char *device) return dsm_fd; } -void +bool dsm_input(void) { ssize_t ret; @@ -141,7 +141,7 @@ dsm_input(void) /* if the read failed for any reason, just give up here */ if (ret < 1) - return; + goto out; last_rx_time = now; /* @@ -153,7 +153,7 @@ dsm_input(void) * If we don't have a full frame, return */ if (partial_frame_count < DSM_FRAME_SIZE) - return; + goto out; /* * Great, it looks like we might have a frame. Go ahead and @@ -161,6 +161,12 @@ dsm_input(void) */ dsm_decode(now); partial_frame_count = 0; + +out: + /* + * If we have seen a frame in the last 200ms, we consider ourselves 'locked' + */ + return (now - last_frame_time) < 200000; } static bool |