diff --git a/src/Core.cc b/src/Core.cc index b49eed18eab00942c85dadd72ccfd89f98197b69..cf0f0c3d1433ed2ae4bda109f4152a6af318327b 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -91,6 +91,8 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) // "Warning: Do not use this function in conjunction with Qt Style Sheets." // setFont(fontDatabase.font(fontFamilyName, "Roman", 12)); + mainWindow = MainWindow::instance(); + // Start the comm link manager splashScreen->showMessage(tr("Starting Communication Links"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); startLinkManager(); @@ -106,6 +108,9 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) splashScreen->showMessage(tr("Starting User Interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); // Start UI + // Remove splash screen + splashScreen->finish(mainWindow); + // Connect links // to make sure that all components are initialized when the // first messages arrive @@ -125,11 +130,6 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) simulationLink->disconnect(); //mainWindow->addLink(simulationLink); - mainWindow = MainWindow::instance(); - - // Remove splash screen - splashScreen->finish(mainWindow); - // Check if link could be connected if (!udpLink->connect()) { diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 38e280aac86b8ebcfa9d36f7ea5aaf1a290e1aa0..dad9d91d1d6397574ad720f99dc8f9c97b0d676e 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -59,7 +59,8 @@ MAVLinkProtocol::MAVLinkProtocol() : heartbeatRate(MAVLINK_HEARTBEAT_DEFAULT_RATE), m_heartbeatsEnabled(false), m_loggingEnabled(false), - m_logfile(NULL) + m_logfile(NULL), + versionMismatchIgnore(false) { start(QThread::LowPriority); // Start heartbeat timer, emitting a heartbeat at the configured rate @@ -91,7 +92,6 @@ MAVLinkProtocol::~MAVLinkProtocol() void MAVLinkProtocol::run() { - } QString MAVLinkProtocol::getLogfileName() @@ -146,7 +146,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) // Check if the UAS has the same id like this system if (message.sysid == getSystemId()) { - qDebug() << "WARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\n\n RECEIVED MESSAGE FROM THIS SYSTEM WITH ID" << message.msgid << "FROM COMPONENT" << message.compid; + emit protocolStatusMessage(tr("SYSTEM ID CONFLICT!"), tr("Warning: A second system is using the same system id (%1)").arg(getSystemId())); } // Create a new UAS based on the heartbeat received @@ -164,9 +164,12 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) if (heartbeat.mavlink_version != MAVLINK_VERSION) { // Bring up dialog to inform user - MainWindow::instance()->showCriticalMessage(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"), + if (!versionMismatchIgnore) + { + emit protocolStatusMessage(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"), tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION)); - + versionMismatchIgnore = true; + } // Ignore this message and continue gracefully continue; diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index d3e436d34b6005f8adb19c3b48a4c8a27f6f9d5c..44ba9489de3b141aed1483c3ed5baf80f4fee11f 100644 --- a/src/comm/MAVLinkProtocol.h +++ b/src/comm/MAVLinkProtocol.h @@ -102,6 +102,7 @@ protected: int totalLossCounter; int currReceiveCounter; int currLossCounter; + bool versionMismatchIgnore; signals: /** @brief Message received and directly copied via signal */ @@ -110,6 +111,8 @@ signals: void heartbeatChanged(bool heartbeats); /** @brief Emitted if logging is started / stopped */ void loggingChanged(bool enabled); + /** @brief Emitted if a message from the protocol should reach the user */ + void protocolStatusMessage(const QString& title, const QString& message); }; #endif // MAVLINKPROTOCOL_H_ diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 9a3f6682819c0ae74b74bee2ce86352d7fded174..51903f427753501a5fe4432dc21adbcb55a3e50c 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -153,6 +153,7 @@ void MainWindow::buildCommonWidgets() { //TODO: move protocol outside UI mavlink = new MAVLinkProtocol(); + connect(mavlink, SIGNAL(protocolStatusMessage(QString,QString)), this, SLOT(showCriticalMessage(QString,QString)), Qt::QueuedConnection); // Dock widgets if (!controlDockWidget)