From e59f00455a3fa0a395d888acec2e95c6e84266e0 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 13 Jun 2016 12:17:52 -0700 Subject: [PATCH] Try initial request 5 times max MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also don’t pop errors for initial request failure on generic vehicle. --- src/FactSystem/ParameterLoader.cc | 14 ++++++++++---- src/FactSystem/ParameterLoader.h | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/FactSystem/ParameterLoader.cc b/src/FactSystem/ParameterLoader.cc index d92d9a1be..d6d0f29f0 100644 --- a/src/FactSystem/ParameterLoader.cc +++ b/src/FactSystem/ParameterLoader.cc @@ -47,6 +47,7 @@ ParameterLoader::ParameterLoader(Vehicle* vehicle) , _defaultComponentId(MAV_COMP_ID_ALL) , _parameterSetMajorVersion(-1) , _parameterMetaData(NULL) + , _initialRequestRetryCount(0) , _totalParamCount(0) { Q_ASSERT(_vehicle); @@ -490,7 +491,7 @@ void ParameterLoader::_waitingParamTimeout(void) foreach(int componentId, _waitingReadParamIndexMap.keys()) { foreach(int paramIndex, _waitingReadParamIndexMap[componentId].keys()) { _waitingReadParamIndexMap[componentId][paramIndex]++; // Bump retry count - if (_waitingReadParamIndexMap[componentId][paramIndex] > _maxInitialLoadRetry) { + if (_waitingReadParamIndexMap[componentId][paramIndex] > _maxInitialLoadRetrySingleParam) { // Give up on this index _failedReadParamIndexMap[componentId] << paramIndex; qCDebug(ParameterLoaderLog) << "Giving up on (componentId:" << componentId << "paramIndex:" << paramIndex << "retryCount:" << _waitingReadParamIndexMap[componentId][paramIndex] << ")"; @@ -978,9 +979,14 @@ void ParameterLoader::_checkInitialLoadComplete(bool failIfNoDefaultComponent) void ParameterLoader::_initialRequestTimeout(void) { - qgcApp()->showMessage("Vehicle did not respond to request for parameters, retrying"); - refreshAllParameters(); - _initialRequestTimeoutTimer.start(); + if (!_vehicle->genericFirmware()) { + // Generic vehicles (like BeBop) may not have any parameters, so don't annoy the user + qgcApp()->showMessage("Vehicle did not respond to request for parameters, retrying"); + } + if (++_initialRequestRetryCount <= _maxInitialRequestListRetry) { + refreshAllParameters(); + _initialRequestTimeoutTimer.start(); + } } QString ParameterLoader::parameterMetaDataFile(MAV_AUTOPILOT firmwareType, int wantedMajorVersion, int& majorVersion, int& minorVersion) diff --git a/src/FactSystem/ParameterLoader.h b/src/FactSystem/ParameterLoader.h index c07650417..b57dcb7ec 100644 --- a/src/FactSystem/ParameterLoader.h +++ b/src/FactSystem/ParameterLoader.h @@ -151,8 +151,10 @@ private: int _parameterSetMajorVersion; ///< Version for parameter set, -1 if not known QObject* _parameterMetaData; ///< Opaque data from FirmwarePlugin::loadParameterMetaDataCall - static const int _maxInitialLoadRetry = 10; ///< Maximum retries for initial index based load - static const int _maxReadWriteRetry = 5; ///< Maximum retries read/write + static const int _maxInitialRequestListRetry = 5; ///< Maximum retries for request list + int _initialRequestRetryCount; ///< Current retry count for request list + static const int _maxInitialLoadRetrySingleParam = 10; ///< Maximum retries for initial index based load of a single param + static const int _maxReadWriteRetry = 5; ///< Maximum retries read/write QMap _paramCountMap; ///< Key: Component id, Value: count of parameters in this component QMap > _waitingReadParamIndexMap; ///< Key: Component id, Value: Map { Key: parameter index still waiting for, Value: retry count } -- 2.22.0