Commit 74c36838 authored by pixhawk's avatar pixhawk

Added MAVLink version check

parent 8838c74b
...@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug> #include <QDebug>
#include <QTime> #include <QTime>
#include <QApplication> #include <QApplication>
#include <QMessageBox>
#include "MG.h" #include "MG.h"
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
...@@ -45,6 +46,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -45,6 +46,7 @@ This file is part of the QGROUNDCONTROL project
#include "ArduPilotMegaMAV.h" #include "ArduPilotMegaMAV.h"
#include "configuration.h" #include "configuration.h"
#include "LinkManager.h" #include "LinkManager.h"
#include "MainWindow.h"
#include <QGCMAVLink.h> #include <QGCMAVLink.h>
#include "QGC.h" #include "QGC.h"
...@@ -141,8 +143,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -141,8 +143,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// of its existence, as it only then can send and receive // of its existence, as it only then can send and receive
// it's first messages. // it's first messages.
// FIXME Current debugging // Check if the UAS has the same id like this system
// check if the UAS has the same id like this system
if (message.sysid == getSystemId()) 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; qDebug() << "WARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\n\n RECEIVED MESSAGE FROM THIS SYSTEM WITH ID" << message.msgid << "FROM COMPONENT" << message.compid;
...@@ -155,7 +156,26 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -155,7 +156,26 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// First create new UAS object // First create new UAS object
// Decode heartbeat message // Decode heartbeat message
mavlink_heartbeat_t heartbeat; mavlink_heartbeat_t heartbeat;
// Reset version field to 0
heartbeat.mavlink_version = 0;
mavlink_msg_heartbeat_decode(&message, &heartbeat); mavlink_msg_heartbeat_decode(&message, &heartbeat);
// Check if the UAS has a different protocol version
if (heartbeat.mavlink_version != MAVLINK_VERSION)
{
// Bring up dialog to inform user
QMessageBox msgBox(MainWindow::instance());
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"));
msgBox.setInformativeText(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));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
// Ignore this message and continue gracefully
continue;
}
switch (heartbeat.autopilot) switch (heartbeat.autopilot)
{ {
case MAV_AUTOPILOT_GENERIC: case MAV_AUTOPILOT_GENERIC:
......
This diff is collapsed.
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Form</class>
<widget class="QWidget" name="Form" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
</widget>
<pixmapfunction></pixmapfunction>
<connections/>
</ui>
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