Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_IOMCU: fixed a safety reset case for IOMCU reset #17522

Merged
merged 1 commit into from May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions libraries/AP_IOMCU/AP_IOMCU.cpp
Expand Up @@ -1038,18 +1038,24 @@ void AP_IOMCU::check_iomcu_reset(void)

if (dt_ms < max_delay) {
// all OK
last_safety_off = reg_status.flag_safety_off;
return;
}
detected_io_reset = true;
INTERNAL_ERROR(AP_InternalError::error_t::iomcu_reset);
hal.console->printf("IOMCU reset t=%u %u %u dt=%u\n",
unsigned(AP_HAL::millis()), unsigned(ts1), unsigned(reg_status.timestamp_ms), unsigned(dt_ms));

if (safety_forced_off && !reg_status.flag_safety_off && hal.util->get_soft_armed()) {
// IOMCU has reset while armed with safety off - force it off
// again so we can keep flying
force_safety_off();
if (last_safety_off && !reg_status.flag_safety_off && hal.util->get_soft_armed()) {
AP_BoardConfig *boardconfig = AP_BoardConfig::get_singleton();
uint16_t options = boardconfig?boardconfig->get_safety_button_options():0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should be raising internal errors in a lot of these places that find boardconfig is nullptr.

Won't ever happen in here AFAICS based on the code sequencing in the various init_ardupilots - but if it did then we wouldn't retry this block and might not reset the safety switch appropriately.

if (safety_forced_off || (options & AP_BoardConfig::BOARD_SAFETY_OPTION_BUTTON_ACTIVE_ARMED) == 0) {
// IOMCU has reset while armed with safety off - force it off
// again so we can keep flying
force_safety_off();
}
}
last_safety_off = reg_status.flag_safety_off;

// we need to ensure the mixer data and the rates are sent over to
// the IOMCU
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_IOMCU/AP_IOMCU.h
Expand Up @@ -154,6 +154,9 @@ class AP_IOMCU {
// have we forced the safety off?
bool safety_forced_off;

// was safety off on last status?
bool last_safety_off;

void send_servo_out(void);
void read_rc_input(void);
void read_servo(void);
Expand Down