From 8b7bc4ad5f3d198ebc6085b5453e789d92ef36ae Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 6 Aug 2015 15:27:43 -0400 Subject: [PATCH] Notify user of vehicle boot errors --- src/FactSystem/ParameterLoader.cc | 38 +++++++++++++++++++++++++------ src/uas/UASMessageHandler.cc | 13 +++++++++++ src/uas/UASMessageHandler.h | 5 ++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/FactSystem/ParameterLoader.cc b/src/FactSystem/ParameterLoader.cc index 165ef96db..a27834501 100644 --- a/src/FactSystem/ParameterLoader.cc +++ b/src/FactSystem/ParameterLoader.cc @@ -29,6 +29,7 @@ #include "QGCLoggingCategory.h" #include "QGCApplication.h" #include "QGCMessageBox.h" +#include "UASMessageHandler.h" #include #include @@ -752,14 +753,37 @@ void ParameterLoader::_checkInitialLoadComplete(void) } } + // Check for any errors during vehicle boot + + UASMessageHandler* msgHandler = UASMessageHandler::instance(); + if (msgHandler->getErrorCount()) { + QString errors; + + msgHandler->lockAccess(); + foreach (UASMessage* msg, msgHandler->messages()) { + if (msg->severityIsError()) { + errors += msg->getText(); + errors += "\n"; + } + } + msgHandler->unlockAccess(); + + QGCMessageBox::critical("Vehicle startup errors", + QString("Errors were detected during vehicle startup:\n" + "%1" + "You should resolve these prior to flight.").arg(errors)); + } + + // Warn of parameter load failure + if (initialLoadFailures) { QGCMessageBox::critical("Parameter Load Failure", - QString("QGroundControl was unable to retrieve the full set of parameters from the vehicle. " - "This will cause QGroundControl to be unable to display it's full user interface. " - "This usually indicates an error in the vehicle's firmware. " - "Please upgrade your firmware to the latest version if possible. " - "If that doesn't work, notify the firmware developers of this error. " - "The following parameter indices could not be loaded after the maximum number of retries: %1.").arg(indexList)); + "QGroundControl was unable to retrieve the full set of parameters from the vehicle. " + "This will cause QGroundControl to be unable to display it's full user interface. " + "If you are using modified firmware, you may need to resolve any vehicle startup errors to resolve the issue. " + "If you are using standard firmware, you may need to upgrade to a newer version to resolve the issue."); + qCWarning(ParameterLoaderLog) << "The following parameter indices could not be loaded after the maximum number of retries: " << indexList; + } else { // No failed parameters, ok to signal ready _parametersReady = true; @@ -767,4 +791,4 @@ void ParameterLoader::_checkInitialLoadComplete(void) _setupGroupMap(); emit parametersReady(); } -} \ No newline at end of file +} diff --git a/src/uas/UASMessageHandler.cc b/src/uas/UASMessageHandler.cc index db2b1be63..926f5183b 100644 --- a/src/uas/UASMessageHandler.cc +++ b/src/uas/UASMessageHandler.cc @@ -38,6 +38,19 @@ UASMessage::UASMessage(int componentid, int severity, QString text) _text = text; } +bool UASMessage::severityIsError() +{ + switch (_severity) { + case MAV_SEVERITY_EMERGENCY: + case MAV_SEVERITY_ALERT: + case MAV_SEVERITY_CRITICAL: + case MAV_SEVERITY_ERROR: + return true; + default: + return false; + } +} + IMPLEMENT_QGC_SINGLETON(UASMessageHandler, UASMessageHandler) UASMessageHandler::UASMessageHandler(QObject *parent) diff --git a/src/uas/UASMessageHandler.h b/src/uas/UASMessageHandler.h index da1d2b40d..00300fc42 100644 --- a/src/uas/UASMessageHandler.h +++ b/src/uas/UASMessageHandler.h @@ -63,6 +63,11 @@ public: * @brief Get (html) formatted text (in the form: "[11:44:21.137 - COMP:50] Info: [pm] sending list") */ QString getFormatedText() { return _formatedText; } + /** + * @return true: This message is a of a severity which is considered an error + */ + bool severityIsError(); + private: UASMessage(int componentid, int severity, QString text); void _setFormatedText(const QString formatedText) { _formatedText = formatedText; } -- 2.22.0