From 8ff3985bc0542b2e381ff23e769311d15b09ae0e Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 6 Mar 2020 10:12:16 -0800 Subject: [PATCH] Give up on getting AUTOPILOT_VERSION based on time now retry count. --- src/Vehicle/Vehicle.cc | 8 ++++++-- src/Vehicle/Vehicle.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 9803371e3..cd824d5de 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -698,12 +698,16 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes } } if (!foundRequest) { - if (++_capabilitiesRetryCount > 5) { + _capabilitiesRetryCount++; + if (_capabilitiesRetryCount == 1) { + _capabilitiesRetryElapsed.start(); + } else if (_capabilitiesRetryElapsed.elapsed() > 10000){ + qCDebug(VehicleLog) << "Giving up on getting AUTOPILOT_VERSION after 10 seconds"; qgcApp()->showMessage(QStringLiteral("Vehicle failed to send AUTOPILOT_VERSION")); _handleUnsupportedRequestAutopilotCapabilities(); } else { // Vehicle never sent us AUTOPILOT_VERSION response. Try again. - qCDebug(VehicleLog) << "Sending MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES again due to no response with AUTOPILOT_VERSION - _capabilitiesRetryCount" << _capabilitiesRetryCount; + qCDebug(VehicleLog) << QStringLiteral("Sending MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES again due to no response with AUTOPILOT_VERSION - _capabilitiesRetryCount(%1) elapsed(%2)").arg(_capabilitiesRetryCount).arg(_capabilitiesRetryElapsed.elapsed()); sendMavCommand(MAV_COMP_ID_ALL, MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES, true, // Show error on failure diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 2ce4a9db6..7e87789a8 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "FactGroup.h" #include "LinkInterface.h" @@ -1431,6 +1432,7 @@ private: QTimer _mavCommandAckTimer; int _mavCommandRetryCount; int _capabilitiesRetryCount = 0; + QTime _capabilitiesRetryElapsed; static const int _mavCommandMaxRetryCount = 3; static const int _mavCommandAckTimeoutMSecs = 3000; static const int _mavCommandAckTimeoutMSecsHighLatency = 120000; -- 2.22.0