diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-07-19 12:53:37 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-07-19 12:53:37 +0200 |
commit | 1575da4390ade717e1fa43a3f18f2348bd494205 (patch) | |
tree | 049aefb4c1cee5b1f9c401c3debeac0b4e1b3209 /src/modules/sensors | |
parent | bcdedd9a35a5b9ebf3851a0d472adab8d3e7edac (diff) | |
parent | a8ac56b9e5eb8c1501ea592b4417aa8becd7236c (diff) | |
download | px4-firmware-1575da4390ade717e1fa43a3f18f2348bd494205.tar.gz px4-firmware-1575da4390ade717e1fa43a3f18f2348bd494205.tar.bz2 px4-firmware-1575da4390ade717e1fa43a3f18f2348bd494205.zip |
Merge branch 'master' of github.com:PX4/Firmware into new_state_machine
Diffstat (limited to 'src/modules/sensors')
-rw-r--r-- | src/modules/sensors/sensors.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 5e334638f..89d5cd374 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -139,14 +139,12 @@ public: private: static const unsigned _rc_max_chan_count = RC_CHANNELS_MAX; /**< maximum number of r/c channels we handle */ -#if CONFIG_HRT_PPM hrt_abstime _ppm_last_valid; /**< last time we got a valid ppm signal */ /** * Gather and publish PPM input data. */ void ppm_poll(); -#endif /* XXX should not be here - should be own driver */ int _fd_adc; /**< ADC driver handle */ @@ -393,9 +391,7 @@ Sensors *g_sensors; } Sensors::Sensors() : -#ifdef CONFIG_HRT_PPM _ppm_last_valid(0), -#endif _fd_adc(-1), _last_adc(0), @@ -1120,16 +1116,18 @@ Sensors::adc_poll(struct sensor_combined_s &raw) } } -#if CONFIG_HRT_PPM void Sensors::ppm_poll() { /* read low-level values from FMU or IO RC inputs (PPM, Spektrum, S.Bus) */ - bool rc_updated; - orb_check(_rc_sub, &rc_updated); + struct pollfd fds[1]; + fds[0].fd = _rc_sub; + fds[0].events = POLLIN; + /* check non-blocking for new data */ + int poll_ret = poll(fds, 1, 0); - if (rc_updated) { + if (poll_ret > 0) { struct rc_input_values rc_input; orb_copy(ORB_ID(input_rc), _rc_sub, &rc_input); @@ -1316,7 +1314,6 @@ Sensors::ppm_poll() } } -#endif void Sensors::task_main_trampoline(int argc, char *argv[]) @@ -1429,10 +1426,8 @@ Sensors::task_main() if (_publishing) orb_publish(ORB_ID(sensor_combined), _sensor_pub, &raw); -#ifdef CONFIG_HRT_PPM /* Look for new r/c input data */ ppm_poll(); -#endif perf_end(_loop_perf); } @@ -1472,7 +1467,7 @@ int sensors_main(int argc, char *argv[]) if (!strcmp(argv[1], "start")) { if (sensors::g_sensors != nullptr) - errx(1, "sensors task already running"); + errx(0, "sensors task already running"); sensors::g_sensors = new Sensors; |