From a09154c45ba369badd61f818e88646b204a09610 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 6 Aug 2018 13:13:32 +1000 Subject: [PATCH] AP_WheelEncoder: correct check for wheelencoder-max-instances --- libraries/AP_WheelEncoder/WheelEncoder_Backend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_WheelEncoder/WheelEncoder_Backend.cpp b/libraries/AP_WheelEncoder/WheelEncoder_Backend.cpp index 06f281c8c8..515689f557 100644 --- a/libraries/AP_WheelEncoder/WheelEncoder_Backend.cpp +++ b/libraries/AP_WheelEncoder/WheelEncoder_Backend.cpp @@ -28,7 +28,7 @@ AP_WheelEncoder_Backend::AP_WheelEncoder_Backend(AP_WheelEncoder &frontend, uint // return pin. returns -1 if pin is not defined for this instance int8_t AP_WheelEncoder_Backend::get_pin_a() const { - if (_state.instance > 1) { + if (_state.instance >= WHEELENCODER_MAX_INSTANCES) { return -1; } return _frontend._pina[_state.instance].get(); @@ -37,7 +37,7 @@ int8_t AP_WheelEncoder_Backend::get_pin_a() const // return pin. returns -1 if pin is not defined for this instance int8_t AP_WheelEncoder_Backend::get_pin_b() const { - if (_state.instance > 1) { + if (_state.instance >= WHEELENCODER_MAX_INSTANCES) { return -1; } return _frontend._pinb[_state.instance].get();