Add RSSI in dBm support, plus LQ, to GHST protocol (#24351)

This commit is contained in:
Tony Cake
2025-02-28 10:53:32 +01:00
committed by GitHub
parent 93b8bc1515
commit ba31054992
5 changed files with 35 additions and 20 deletions
+7 -6
View File
@@ -34,6 +34,7 @@
#include "GhstRc.hpp"
#include <termios.h>
#include <math.h>
GhstRc::GhstRc(const char *device) :
ModuleParams(nullptr),
@@ -174,16 +175,18 @@ void GhstRc::Run()
if (newBytes > 0) {
uint16_t raw_rc_values[input_rc_s::RC_INPUT_MAX_CHANNELS] {};
uint16_t raw_rc_count = 0;
int8_t ghst_rssi = -1;
ghstLinkStatistics_t link_stats = { .rssi_pct = -1, .rssi_dbm = NAN, .link_quality = 0 };
if (ghst_parse(cycle_timestamp, &rcs_buf[0], newBytes, &raw_rc_values[0], &ghst_rssi,
if (ghst_parse(cycle_timestamp, &rcs_buf[0], newBytes, &raw_rc_values[0], &link_stats,
&raw_rc_count, input_rc_s::RC_INPUT_MAX_CHANNELS)
) {
// we have a new GHST frame. Publish it.
input_rc_s input_rc{};
input_rc.timestamp_last_signal = cycle_timestamp;
input_rc.channel_count = math::constrain(raw_rc_count, (uint16_t)0, (uint16_t)input_rc_s::RC_INPUT_MAX_CHANNELS);
input_rc.rssi = ghst_rssi;
input_rc.rssi = link_stats.rssi_pct;
input_rc.link_quality = link_stats.link_quality;
input_rc.rssi_dbm = link_stats.rssi_dbm;
input_rc.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_GHST;
unsigned valid_chans = 0;
@@ -200,13 +203,11 @@ void GhstRc::Run()
if (valid_chans == 0) {
input_rc.rssi = 0;
// can't force link quality to zero here, receiver takes care of this
}
input_rc.rc_lost = (valid_chans == 0);
input_rc.link_quality = -1;
input_rc.rssi_dbm = NAN;
input_rc.timestamp = hrt_absolute_time();
_input_rc_pub.publish(input_rc);
perf_count(_publish_interval_perf);
+4 -3
View File
@@ -762,14 +762,15 @@ void RCInput::Run()
// parse new data
if (newBytes > 0) {
int8_t ghst_rssi = -1;
rc_updated = ghst_parse(cycle_timestamp, &_rcs_buf[0], newBytes, &_raw_rc_values[0], &ghst_rssi,
ghstLinkStatistics_t link_stats = { .rssi_pct = -1, .rssi_dbm = NAN, .link_quality = 0 };
rc_updated = ghst_parse(cycle_timestamp, &_rcs_buf[0], newBytes, &_raw_rc_values[0], &link_stats,
&_raw_rc_count, input_rc_s::RC_INPUT_MAX_CHANNELS);
if (rc_updated) {
// we have a new GHST frame. Publish it.
_input_rc.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_GHST;
int32_t valid_chans = fill_rc_in(_raw_rc_count, _raw_rc_values, cycle_timestamp, false, false, 0, ghst_rssi);
int32_t valid_chans = fill_rc_in(_raw_rc_count, _raw_rc_values, cycle_timestamp, false, false, 0, link_stats.rssi_pct);
// ghst telemetry works on fmu-v5
// on other Pixhawk (-related) boards we cannot write to the RC UART