diff --git a/src/FactSystem/ParameterLoader.cc b/src/FactSystem/ParameterLoader.cc index 165ef96db78b853b61ca8b4ff44717129eb733a3..a27834501839a0ea95aee4bbbb8e58349e3247d3 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 db2b1be6391b9662b08e1ad67812aac6b3482006..926f5183b4bb54b9e3b443ac3822cf0d2277f3c5 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 da1d2b40dfa1c8aa00d543e0069117900929112c..00300fc4209925b68ac4541f0d1f37e8a3985096 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; }