From a255c47c33a60b63eddbf698c6f9bd2c729446b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 14 Feb 2018 22:59:14 -0200 Subject: [PATCH] AP_GPS: Do not restart driver if type is defined as MAV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix bluerobotics/ardusub#104 Signed-off-by: Patrick José Pereira --- libraries/AP_GPS/AP_GPS.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/AP_GPS/AP_GPS.cpp b/libraries/AP_GPS/AP_GPS.cpp index cc1e079758..9cbbd77ea4 100644 --- a/libraries/AP_GPS/AP_GPS.cpp +++ b/libraries/AP_GPS/AP_GPS.cpp @@ -626,17 +626,22 @@ void AP_GPS::update_instance(uint8_t instance) // detection to run again if (!result) { if (tnow - timing[instance].last_message_time_ms > GPS_TIMEOUT_MS) { - // free the driver before we run the next detection, so we - // don't end up with two allocated at any time - delete drivers[instance]; - drivers[instance] = nullptr; memset(&state[instance], 0, sizeof(state[instance])); state[instance].instance = instance; - state[instance].status = NO_GPS; state[instance].hdop = GPS_UNKNOWN_DOP; state[instance].vdop = GPS_UNKNOWN_DOP; timing[instance].last_message_time_ms = tnow; timing[instance].delta_time_ms = GPS_TIMEOUT_MS; + // do not try to detect again if type is MAV + if (_type[instance] == GPS_TYPE_MAV) { + state[instance].status = NO_FIX; + } else { + // free the driver before we run the next detection, so we + // don't end up with two allocated at any time + delete drivers[instance]; + drivers[instance] = nullptr; + state[instance].status = NO_GPS; + } } } else { // delta will only be correct after parsing two messages