aboutsummaryrefslogtreecommitdiff
path: root/apps/sensors
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-08-08 18:47:46 +0200
committerLorenz Meier <lm@inf.ethz.ch>2012-08-08 18:47:46 +0200
commit7a912a3fe47bced7c04d948cc3da094fea7542bc (patch)
treed653955dc344c26eb63550432c75c0589ae82e5f /apps/sensors
parent7a6a4b93525ea62484a5df02f392b72a519ac248 (diff)
downloadpx4-firmware-7a912a3fe47bced7c04d948cc3da094fea7542bc.tar.gz
px4-firmware-7a912a3fe47bced7c04d948cc3da094fea7542bc.tar.bz2
px4-firmware-7a912a3fe47bced7c04d948cc3da094fea7542bc.zip
Minor but important fixes across system
Diffstat (limited to 'apps/sensors')
-rw-r--r--apps/sensors/sensors.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/apps/sensors/sensors.c b/apps/sensors/sensors.c
index 461b9805d..b456c4dfb 100644
--- a/apps/sensors/sensors.c
+++ b/apps/sensors/sensors.c
@@ -116,6 +116,7 @@ static void sensors_timer_loop(void *arg);
#ifdef CONFIG_HRT_PPM
extern uint16_t ppm_buffer[];
extern unsigned ppm_decoded_channels;
+extern uint64_t ppm_last_valid_decode;
#endif
/* file handle that will be used for subscribing */
@@ -705,21 +706,23 @@ int sensors_main(int argc, char *argv[])
/* PPM */
if (ppmcounter == 5) {
- /* Read out values from HRT */
- for (int i = 0; i < ppm_decoded_channels; i++) {
- rc.chan[i].raw = ppm_buffer[i];
- /* Set the range to +-, then scale up */
- rc.chan[i].scale = (ppm_buffer[i] - rc.chan[i].mid) * rc.chan[i].scaling_factor;
- }
-
- rc.chan_count = ppm_decoded_channels;
-
- rc.timestamp = hrt_absolute_time();
- /* publish a few lines of code later if set to true */
- ppm_updated = true;
+ /* require at least two channels
+ * to consider the signal valid
+ */
+ if (ppm_decoded_channels > 1 && (hrt_absolute_time() - ppm_last_valid_decode) < 45000) {
+ /* Read out values from HRT */
+ for (int i = 0; i < ppm_decoded_channels; i++) {
+ rc.chan[i].raw = ppm_buffer[i];
+ /* Set the range to +-, then scale up */
+ rc.chan[i].scale = (ppm_buffer[i] - rc.chan[i].mid) * rc.chan[i].scaling_factor;
+ }
+ rc.chan_count = ppm_decoded_channels;
- //TODO: XXX check the mode switch channel and eventually send a request to the commander (see implementation in commander and mavlink)
+ rc.timestamp = ppm_last_valid_decode;
+ /* publish a few lines of code later if set to true */
+ ppm_updated = true;
+ }
ppmcounter = 0;
}