Commit f7e8ba99 authored by Don Gagne's avatar Don Gagne

Merge pull request #1763 from mavlink/BootReport

Boot report
parents c9a4636c f25e7e07
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "UASMessageHandler.h"
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
...@@ -752,14 +753,37 @@ void ParameterLoader::_checkInitialLoadComplete(void) ...@@ -752,14 +753,37 @@ void ParameterLoader::_checkInitialLoadComplete(void)
} }
} }
// Check for any errors during vehicle boot
UASMessageHandler* msgHandler = UASMessageHandler::instance();
if (msgHandler->getErrorCountTotal()) {
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) { if (initialLoadFailures) {
QGCMessageBox::critical("Parameter Load Failure", QGCMessageBox::critical("Parameter Load Failure",
QString("QGroundControl was unable to retrieve the full set of parameters from the vehicle. " "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 will cause QGroundControl to be unable to display it's full user interface. "
"This usually indicates an error in the vehicle's firmware. " "If you are using modified firmware, you may need to resolve any vehicle startup errors to resolve the issue. "
"Please upgrade your firmware to the latest version if possible. " "If you are using standard firmware, you may need to upgrade to a newer version to resolve the issue.");
"If that doesn't work, notify the firmware developers of this error. " qCWarning(ParameterLoaderLog) << "The following parameter indices could not be loaded after the maximum number of retries: " << indexList;
"The following parameter indices could not be loaded after the maximum number of retries: %1.").arg(indexList));
} else { } else {
// No failed parameters, ok to signal ready // No failed parameters, ok to signal ready
_parametersReady = true; _parametersReady = true;
......
...@@ -38,12 +38,26 @@ UASMessage::UASMessage(int componentid, int severity, QString text) ...@@ -38,12 +38,26 @@ UASMessage::UASMessage(int componentid, int severity, QString text)
_text = 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) IMPLEMENT_QGC_SINGLETON(UASMessageHandler, UASMessageHandler)
UASMessageHandler::UASMessageHandler(QObject *parent) UASMessageHandler::UASMessageHandler(QObject *parent)
: QGCSingleton(parent) : QGCSingleton(parent)
, _activeUAS(NULL) , _activeUAS(NULL)
, _errorCount(0) , _errorCount(0)
, _errorCountTotal(0)
, _warningCount(0) , _warningCount(0)
, _normalCount(0) , _normalCount(0)
{ {
...@@ -112,6 +126,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -112,6 +126,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
//Use set RGB values from given color from QGC //Use set RGB values from given color from QGC
style = QString("color: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorRed.red()).arg(QGC::colorRed.green()).arg(QGC::colorRed.blue()); style = QString("color: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorRed.red()).arg(QGC::colorRed.green()).arg(QGC::colorRed.blue());
_errorCount++; _errorCount++;
_errorCountTotal++;
break; break;
case MAV_SEVERITY_NOTICE: case MAV_SEVERITY_NOTICE:
case MAV_SEVERITY_WARNING: case MAV_SEVERITY_WARNING:
...@@ -163,22 +178,21 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -163,22 +178,21 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
message->_setFormatedText(QString("<p style=\"color:#CCCCCC\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text)); message->_setFormatedText(QString("<p style=\"color:#CCCCCC\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text));
_messages.append(message); _messages.append(message);
int count = _messages.count(); int count = _messages.count();
switch (severity) if (message->severityIsError()) {
{
case MAV_SEVERITY_EMERGENCY:
case MAV_SEVERITY_ALERT:
case MAV_SEVERITY_CRITICAL:
case MAV_SEVERITY_ERROR:
_latestError = severityText + " " + text; _latestError = severityText + " " + text;
break;
default:
break;
} }
_mutex.unlock(); _mutex.unlock();
emit textMessageReceived(message); emit textMessageReceived(message);
emit textMessageCountChanged(count); emit textMessageCountChanged(count);
} }
int UASMessageHandler::getErrorCountTotal() {
_mutex.lock();
int c = _errorCountTotal;
_mutex.unlock();
return c;
}
int UASMessageHandler::getErrorCount() { int UASMessageHandler::getErrorCount() {
_mutex.lock(); _mutex.lock();
int c = _errorCount; int c = _errorCount;
......
...@@ -63,6 +63,11 @@ public: ...@@ -63,6 +63,11 @@ public:
* @brief Get (html) formatted text (in the form: "[11:44:21.137 - COMP:50] Info: [pm] sending list") * @brief Get (html) formatted text (in the form: "[11:44:21.137 - COMP:50] Info: [pm] sending list")
*/ */
QString getFormatedText() { return _formatedText; } QString getFormatedText() { return _formatedText; }
/**
* @return true: This message is a of a severity which is considered an error
*/
bool severityIsError();
private: private:
UASMessage(int componentid, int severity, QString text); UASMessage(int componentid, int severity, QString text);
void _setFormatedText(const QString formatedText) { _formatedText = formatedText; } void _setFormatedText(const QString formatedText) { _formatedText = formatedText; }
...@@ -99,6 +104,10 @@ public: ...@@ -99,6 +104,10 @@ public:
* @brief Get error message count (Resets count once read) * @brief Get error message count (Resets count once read)
*/ */
int getErrorCount(); int getErrorCount();
/**
* @brief Get error message count (never reset)
*/
int getErrorCountTotal();
/** /**
* @brief Get warning message count (Resets count once read) * @brief Get warning message count (Resets count once read)
*/ */
...@@ -142,6 +151,7 @@ private: ...@@ -142,6 +151,7 @@ private:
QVector<UASMessage*> _messages; QVector<UASMessage*> _messages;
QMutex _mutex; QMutex _mutex;
int _errorCount; int _errorCount;
int _errorCountTotal;
int _warningCount; int _warningCount;
int _normalCount; int _normalCount;
QString _latestError; QString _latestError;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment