AC_Fence: prevent a fetch R/C switch from disabling FENCE_AUTOENABLE=3

we should only add fence types to the no auto-enable mask if the
enable actually changed that type of fence. This fixes the case where
the user has both FENCE_AUTOENABLE=3 and RCn_OPTION=11. The disable
triggered by the init of the aux function was preventing the fence
from auto-enabling
This commit is contained in:
Andrew Tridgell 2024-11-25 13:53:22 +11:00
parent 42ad2a7911
commit f6726e66f8
1 changed files with 6 additions and 5 deletions

View File

@ -250,16 +250,17 @@ uint8_t AC_Fence::enable(bool value, uint8_t fence_types, bool update_auto_mask)
enabled_fences &= ~fences;
}
// fences that were manually changed are no longer eligible for auto-enablement or disablement
if (update_auto_mask) {
_auto_enable_mask &= ~fences;
}
uint8_t fences_to_change = _enabled_fences ^ enabled_fences;
if (!fences_to_change) {
return 0;
}
// fences that were manually changed are no longer eligible for auto-enablement or disablement
if (update_auto_mask) {
_auto_enable_mask &= ~fences_to_change;
}
#if HAL_LOGGING_ENABLED
AP::logger().Write_Event(value ? LogEvent::FENCE_ENABLE : LogEvent::FENCE_DISABLE);
if (fences_to_change & AC_FENCE_TYPE_ALT_MAX) {