From 456414074576f926cd58699522ab1f2c94b1b6cd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 27 Mar 2022 17:31:20 +1100 Subject: [PATCH] HAL_ChibiOS: display source of RC input distinguish between IOMCU, RCInput with bytes and RCInput with pulses --- libraries/AP_HAL_ChibiOS/RCInput.cpp | 13 ++++++++++--- libraries/AP_HAL_ChibiOS/RCInput.h | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/RCInput.cpp b/libraries/AP_HAL_ChibiOS/RCInput.cpp index 9e6cfeb813..6ea3436d9c 100644 --- a/libraries/AP_HAL_ChibiOS/RCInput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCInput.cpp @@ -150,6 +150,7 @@ void RCInput::_timer_tick(void) } #ifndef HAL_NO_UARTDRIVER const char *rc_protocol = nullptr; + RCSource source = last_source; #endif #ifndef HAL_BUILD_AP_PERIPH @@ -191,12 +192,13 @@ void RCInput::_timer_tick(void) _rx_link_quality = rcprot.get_rx_link_quality(); #ifndef HAL_NO_UARTDRIVER rc_protocol = rcprot.protocol_name(); + source = rcprot.using_uart() ? RCSource::RCPROT_BYTES : RCSource::RCPROT_PULSES; #endif } #endif // HAL_BUILD_AP_PERIPH #if HAL_RCINPUT_WITH_AP_RADIO - if (radio && radio->last_recv_us() != last_radio_us) { + if (radio && radio->last_recv_us() != last_radio_us && !have_iocmu_rc) { last_radio_us = radio->last_recv_us(); WITH_SEMAPHORE(rcin_mutex); _rcin_timestamp_last_signal = last_radio_us; @@ -205,6 +207,9 @@ void RCInput::_timer_tick(void) for (uint8_t i=0; i<_num_channels; i++) { _rc_values[i] = radio->read(i); } +#ifndef HAL_NO_UARTDRIVER + source = RCSource::APRADIO; +#endif } #endif @@ -218,15 +223,17 @@ void RCInput::_timer_tick(void) #ifndef HAL_NO_UARTDRIVER rc_protocol = iomcu.get_rc_protocol(); _rssi = iomcu.get_RSSI(); + source = RCSource::IOMCU; #endif } } #endif #ifndef HAL_NO_UARTDRIVER - if (rc_protocol && rc_protocol != last_protocol) { + if (rc_protocol && (rc_protocol != last_protocol || source != last_source)) { last_protocol = rc_protocol; - GCS_SEND_TEXT(MAV_SEVERITY_DEBUG, "RCInput: decoding %s", last_protocol); + last_source = source; + GCS_SEND_TEXT(MAV_SEVERITY_DEBUG, "RCInput: decoding %s(%u)", last_protocol, unsigned(source)); } #endif diff --git a/libraries/AP_HAL_ChibiOS/RCInput.h b/libraries/AP_HAL_ChibiOS/RCInput.h index 48eff5767b..08ba46d58c 100644 --- a/libraries/AP_HAL_ChibiOS/RCInput.h +++ b/libraries/AP_HAL_ChibiOS/RCInput.h @@ -72,6 +72,15 @@ private: uint32_t _rcin_last_iomcu_ms; bool _init; const char *last_protocol; + + enum class RCSource { + NONE = 0, + IOMCU = 1, + RCPROT_PULSES = 2, + RCPROT_BYTES = 3, + APRADIO = 4, + } last_source; + bool pulse_input_enabled; #if HAL_RCINPUT_WITH_AP_RADIO