From 768e2409df1864334544adf35d54832c8b57f1a1 Mon Sep 17 00:00:00 2001 From: James O'Shannessy <12959316+joshanne@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:48:19 +1000 Subject: [PATCH] AP_Relay: check enabled relay mask for passing relay outputs to hardware --- libraries/AP_Relay/AP_Relay.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Relay/AP_Relay.cpp b/libraries/AP_Relay/AP_Relay.cpp index 859cf27685..1c4cb143f7 100644 --- a/libraries/AP_Relay/AP_Relay.cpp +++ b/libraries/AP_Relay/AP_Relay.cpp @@ -156,8 +156,10 @@ void AP_Relay::set(const uint8_t instance, const bool value) _last_log_ms = now; _last_logged_pin_states = _pin_states; } -#if AP_SIM_ENABLED && (CONFIG_HAL_BOARD != HAL_BOARD_SITL) - return; +#if AP_SIM_ENABLED + if (!(AP::sitl()->on_hardware_relay_enable_mask & (1U << instance))) { + return; + } #endif hal.gpio->pinMode(_pin[instance], HAL_GPIO_OUTPUT); hal.gpio->write(_pin[instance], value);