@@ -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)
// Check if the UAS has a different protocol version
if(heartbeat.mavlink_version!=MAVLINK_VERSION)
{
// Bring up dialog to inform user
QMessageBoxmsgBox(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));
emitparseState(QString("<font color=\"red\">ERROR: Protocol version tag set twice, please use it only once. First version was %1, second version is %2.\nAbort.</font>").arg(mavlinkVersion).arg(fieldText));
returnfalse;
}
boolok;
intversion=fieldText.toInt(&ok);
if(ok&&(version>0)&&(version<256))
{
// Set MAVLink version
mavlinkVersion=version;
}
else
{
emitparseState(QString("<font color=\"red\">ERROR: Reading version string failed: %1, string is not an integer number between 1 and 255.\nAbort.</font>").arg(fieldText));
QStringcommentContainer("/**\n * @brief Send a %1 message\n *\n%2 * @return length of the message in bytes (excluding serial stream start sign)\n */\n");
QStringcommentContainer("/**\n * @brief Pack a %1 message\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param msg The MAVLink message to compress the data into\n *\n%2 * @return length of the message in bytes (excluding serial stream start sign)\n */\n");
QStringcommentPackChanContainer("/**\n * @brief Pack a %1 message\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param chan The MAVLink channel this message was sent over\n * @param msg The MAVLink message to compress the data into\n%2 * @return length of the message in bytes (excluding serial stream start sign)\n */\n");
QStringcommentSendContainer("/**\n * @brief Send a %1 message\n * @param chan MAVLink channel to send the message\n *\n%2 */\n");
QStringcommentEncodeContainer("/**\n * @brief Encode a %1 struct into a message\n *\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param msg The MAVLink message to compress the data into\n * @param %1 C-struct to read the message contents from\n */\n");
QStringcommentDecodeContainer("/**\n * @brief Decode a %1 message into a struct\n *\n * @param msg The message to decode\n * @param %1 C-struct to decode the message contents into\n */\n");