diff --git a/libraries/AP_ServoRelayEvents/AP_ServoRelayEvents.cpp b/libraries/AP_ServoRelayEvents/AP_ServoRelayEvents.cpp index a912223ab6..8c1429f935 100644 --- a/libraries/AP_ServoRelayEvents/AP_ServoRelayEvents.cpp +++ b/libraries/AP_ServoRelayEvents/AP_ServoRelayEvents.cpp @@ -21,6 +21,7 @@ #include #include "AP_ServoRelayEvents.h" #include +#include extern const AP_HAL::HAL& hal; @@ -102,13 +103,17 @@ void AP_ServoRelayEvents::update_events(void) return; } + if (channel > NUM_SERVO_CHANNELS || channel == 0) { + return; + } + start_time_ms = AP_HAL::millis(); switch (type) { case EVENT_TYPE_SERVO: hal.rcout->enable_ch(channel-1); if (repeat & 1) { - hal.rcout->write(channel-1, RC_Channel::rc_channel(channel-1)->get_radio_trim()); + hal.rcout->write(channel-1, SRV_Channels::srv_channel(channel-1)->get_output_pwm()); } else { hal.rcout->write(channel-1, servo_value); }