diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-16 15:31:44 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-16 15:31:44 +0100 |
commit | e56911bf2d637682f64fe93add114f8fef2682fd (patch) | |
tree | 0551e3d678cda4105574c961f0f95745bbadb634 /apps/px4io/controls.c | |
parent | f81d00594c156c51ab976d3b6d101915377d7afa (diff) | |
download | px4-firmware-e56911bf2d637682f64fe93add114f8fef2682fd.tar.gz px4-firmware-e56911bf2d637682f64fe93add114f8fef2682fd.tar.bz2 px4-firmware-e56911bf2d637682f64fe93add114f8fef2682fd.zip |
Fixed signal loss detection on S.Bus parsing, stripped PX4IO code parts from S.Bus parser to allow FMU / IO parser code sharing. Added S.Bus channels 17 and 18 if channel data struct has enough space. Tested with receiver and PX4FMU.
Diffstat (limited to 'apps/px4io/controls.c')
-rw-r--r-- | apps/px4io/controls.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/apps/px4io/controls.c b/apps/px4io/controls.c index 4bd6fe1a0..48370d9d0 100644 --- a/apps/px4io/controls.c +++ b/apps/px4io/controls.c @@ -92,10 +92,22 @@ controls_main(void) */ bool locked = false; + /* + * Store RC channel count to detect switch to RC loss sooner + * than just by timeout + */ + unsigned rc_channels = system_state.rc_channels; + + /* + * Track if any input got an update in this round + */ + bool rc_updated; + if (fds[0].revents & POLLIN) locked |= dsm_input(); if (fds[1].revents & POLLIN) - locked |= sbus_input(); + locked |= sbus_input(fds[1].fd, PX4IO_INPUT_CHANNELS, &system_state.rc_channel_data, + &system_state.rc_channels, &system_state.rc_channels_timestamp, &rc_updated); /* * If we don't have lock from one of the serial receivers, @@ -127,13 +139,21 @@ controls_main(void) /* set the number of channels to zero - no inputs */ system_state.rc_channels = 0; - system_state.rc_lost = true; - - /* trigger an immediate report to the FMU */ - system_state.fmu_report_due = true; + rc_updated = true; } - /* PWM output updates are performed directly on each comms update */ + /* + * If there was a RC update OR the RC signal status (lost / present) has + * just changed, request an update immediately. + */ + system_state.fmu_report_due |= rc_updated; + + /* + * PWM output updates are performed in addition on each comm update. + * the updates here are required to ensure operation if FMU is not started + * or stopped responding. + */ + mixer_tick(); } } |