From a88693c48758b7df7e2ebfd65a857d2f4f4ed798 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Jun 2017 13:12:58 +1000 Subject: [PATCH] HAL_PX4: support RSSI from receiver protocols --- libraries/AP_HAL_PX4/RCInput.cpp | 4 ++++ libraries/AP_HAL_PX4/RCInput.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/libraries/AP_HAL_PX4/RCInput.cpp b/libraries/AP_HAL_PX4/RCInput.cpp index 4876399593..fb8e06cdf8 100644 --- a/libraries/AP_HAL_PX4/RCInput.cpp +++ b/libraries/AP_HAL_PX4/RCInput.cpp @@ -118,6 +118,10 @@ void PX4RCInput::_timer_tick(void) if (orb_check(_rc_sub, &rc_updated) == 0 && rc_updated) { pthread_mutex_lock(&rcin_mutex); orb_copy(ORB_ID(input_rc), _rc_sub, &_rcin); + if (_rcin.rssi != 0 || _rssi != -1) { + // always zero means not supported + _rssi = _rcin.rssi; + } pthread_mutex_unlock(&rcin_mutex); } // note, we rely on the vehicle code checking new_input() diff --git a/libraries/AP_HAL_PX4/RCInput.h b/libraries/AP_HAL_PX4/RCInput.h index 4421fe945a..07665a4cc0 100644 --- a/libraries/AP_HAL_PX4/RCInput.h +++ b/libraries/AP_HAL_PX4/RCInput.h @@ -18,6 +18,11 @@ public: uint16_t read(uint8_t ch) override; uint8_t read(uint16_t* periods, uint8_t len) override; + int16_t get_rssi(void) override { + return _rssi; + } + + bool set_overrides(int16_t *overrides, uint8_t len) override; bool set_override(uint8_t channel, int16_t override) override; void clear_overrides() override; @@ -35,4 +40,5 @@ private: bool _override_valid; perf_counter_t _perf_rcin; pthread_mutex_t rcin_mutex; + int16_t _rssi = -1; };