diff --git a/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp b/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp index 6060eec2a6..de5e4d3d72 100644 --- a/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp +++ b/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp @@ -91,7 +91,7 @@ bool AP_ESC_Telem::get_rpm(uint8_t esc_index, float& rpm) const { const volatile AP_ESC_Telem_Backend::RpmData& rpmdata = _rpm_data[esc_index]; - if (esc_index > ESC_TELEM_MAX_ESCS || is_zero(rpmdata.update_rate_hz)) { + if (esc_index >= ESC_TELEM_MAX_ESCS || is_zero(rpmdata.update_rate_hz)) { return false; } @@ -288,7 +288,7 @@ void AP_ESC_Telem::update_telem_data(const uint8_t esc_index, const AP_ESC_Telem // can only get slightly more up-to-date information that perhaps they were expecting or might // read data that has just gone stale - both of these are safe and avoid the overhead of locking - if (esc_index > ESC_TELEM_MAX_ESCS) { + if (esc_index >= ESC_TELEM_MAX_ESCS) { return; } @@ -322,7 +322,7 @@ void AP_ESC_Telem::update_telem_data(const uint8_t esc_index, const AP_ESC_Telem // this should be called by backends when new telemetry values are available void AP_ESC_Telem::update_rpm(const uint8_t esc_index, const uint16_t new_rpm, const float error_rate) { - if (esc_index > ESC_TELEM_MAX_ESCS) { + if (esc_index >= ESC_TELEM_MAX_ESCS) { return; }