forked from Archive/PX4-Autopilot
px4io: input_rc only publish new successful decodes
- previously an invalid decode would continue to be transferred to the FMU (at 50 Hz) and published to the rest of the system as successfully decoded new RC data - by only publishing new successful decodes we can more effectively discard invalid data in downstream consumers
This commit is contained in:
parent
017f860f44
commit
091fca701e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -202,6 +202,8 @@ private:
|
||||||
|
|
||||||
hrt_abstime _last_status_publish{0};
|
hrt_abstime _last_status_publish{0};
|
||||||
|
|
||||||
|
uint16_t _rc_valid_update_count{0};
|
||||||
|
|
||||||
bool _param_update_force{true}; ///< force a parameter update
|
bool _param_update_force{true}; ///< force a parameter update
|
||||||
bool _timer_rates_configured{false};
|
bool _timer_rates_configured{false};
|
||||||
|
|
||||||
|
@ -1198,6 +1200,14 @@ int PX4IO::io_get_status()
|
||||||
|
|
||||||
int PX4IO::io_publish_raw_rc()
|
int PX4IO::io_publish_raw_rc()
|
||||||
{
|
{
|
||||||
|
const uint16_t rc_valid_update_count = io_reg_get(PX4IO_PAGE_RAW_RC_INPUT, PX4IO_P_RAW_FRAME_COUNT);
|
||||||
|
const bool rc_updated = (rc_valid_update_count != _rc_valid_update_count);
|
||||||
|
_rc_valid_update_count = rc_valid_update_count;
|
||||||
|
|
||||||
|
if (!rc_updated) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
input_rc_s input_rc{};
|
input_rc_s input_rc{};
|
||||||
input_rc.timestamp_last_signal = hrt_absolute_time();
|
input_rc.timestamp_last_signal = hrt_absolute_time();
|
||||||
|
|
||||||
|
@ -1306,8 +1316,7 @@ int PX4IO::io_publish_raw_rc()
|
||||||
input_rc.input_source = input_rc_s::RC_INPUT_SOURCE_PX4IO_ST24;
|
input_rc.input_source = input_rc_s::RC_INPUT_SOURCE_PX4IO_ST24;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((input_rc.channel_count > 0) && !input_rc.rc_lost && !input_rc.rc_failsafe
|
if (input_rc.input_source != input_rc_s::RC_INPUT_SOURCE_UNKNOWN) {
|
||||||
&& (input_rc.input_source != input_rc_s::RC_INPUT_SOURCE_UNKNOWN)) {
|
|
||||||
|
|
||||||
_to_input_rc.publish(input_rc);
|
_to_input_rc.publish(input_rc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,6 +369,8 @@ controls_tick()
|
||||||
} else {
|
} else {
|
||||||
r_raw_rc_flags &= ~(PX4IO_P_RAW_RC_FLAGS_MAPPING_OK);
|
r_raw_rc_flags &= ~(PX4IO_P_RAW_RC_FLAGS_MAPPING_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r_page_raw_rc_input[PX4IO_P_RAW_FRAME_COUNT]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue