Commit 87a8f9e5 authored by pixhawk's avatar pixhawk

Fixed version check to not brick application any more

parent 0e044f6c
......@@ -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())
{
......
......@@ -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;
......
......@@ -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_
......@@ -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)
......
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