Skip to content

Commit

Permalink
px4io: input_rc only publish new successful decodes
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
dagar authored Apr 9, 2022
1 parent 017f860 commit 091fca7
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 2 deletions.
Binary file modified boards/cubepilot/cubeorange/extras/cubepilot_io-v2_default.bin
Binary file not shown.
Binary file modified boards/cubepilot/cubeyellow/extras/cubepilot_io-v2_default.bin
Binary file not shown.
Binary file modified boards/holybro/durandal-v1/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/holybro/pix32v5/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/mro/x21-777/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v2/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v3/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v4pro/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v5/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v5x/extras/px4_io-v2_default.bin
Binary file not shown.
Binary file modified boards/px4/fmu-v6x/extras/px4_io-v2_default.bin
Binary file not shown.
13 changes: 11 additions & 2 deletions src/drivers/px4io/px4io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ class PX4IO : public cdev::CDev, public ModuleBase<PX4IO>, public OutputModuleIn

hrt_abstime _last_status_publish{0};

uint16_t _rc_valid_update_count{0};

bool _param_update_force{true}; ///< force a parameter update
bool _timer_rates_configured{false};

Expand Down Expand Up @@ -1198,6 +1200,14 @@ int PX4IO::io_get_status()

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.timestamp_last_signal = hrt_absolute_time();

Expand Down Expand Up @@ -1306,8 +1316,7 @@ int PX4IO::io_publish_raw_rc()
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
&& (input_rc.input_source != input_rc_s::RC_INPUT_SOURCE_UNKNOWN)) {
if (input_rc.input_source != input_rc_s::RC_INPUT_SOURCE_UNKNOWN) {

_to_input_rc.publish(input_rc);
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/px4iofirmware/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ controls_tick()
} else {
r_raw_rc_flags &= ~(PX4IO_P_RAW_RC_FLAGS_MAPPING_OK);
}

r_page_raw_rc_input[PX4IO_P_RAW_FRAME_COUNT]++;
}

/*
Expand Down

0 comments on commit 091fca7

Please # to comment.