#ifdef myadd
#endif
之间的代码是我加的
void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
{
// Since receiveBytes signals cross threads we can end up with signals in the queue
// that come through after the link is disconnected. For these we just drop the data
// since the link is closed.
if (!_linkMgr->containsLink(link)) {
return;
}
// receiveMutex.lock();
mavlink_message_t message;
mavlink_status_t status;
int mavlinkChannel = link->mavlinkChannel();
static int nonmavlinkCount = 0;
static bool checkedUserNonMavlink = false;
static bool warnedUserNonMavlink = false;
for (int position = 0; position < b.size(); position++) {
unsigned int decodeState = mavlink_parse_char(mavlinkChannel, (uint8_t)(b[position]), &message, &status);
if (decodeState == 0 && !link->decodedFirstMavlinkPacket())
{
nonmavlinkCount++;
#ifdef myadd
if (b[0]==0xD3&&b[1]==0x00){
qDebug() <<"now it is on b1"<<b;
RTCMMavlink * mavlink123 = new RTCMMavlink(*_toolbox);
int blength =b.size();
QByteArray message(b, blength);
mavlink123->RTCMDataUpdate(message);
break;
}
#endif
if (nonmavlinkCount > 1000 && !warnedUserNonMavlink)
{
// 500 bytes with no mavlink message. Are we connected to a mavlink capable device?
if (!checkedUserNonMavlink)
{
link->requestReset();
checkedUserNonMavlink = true;
}
else
{
warnedUserNonMavlink = true;
// Disconnect the link since its some other device and
// QGC clinging on to it and feeding it data might have unintended
// side effects (e.g. if its a modem)
qDebug() << "disconnected link" << link->getName() << "as it contained no MAVLink data";
#ifdef myadd
if (b[0]==0xD3&&b[1]==0x00){
qDebug() <<"now it is on b2"<<b;
RTCMMavlink * mavlink1234 = new RTCMMavlink(*_toolbox);
int blength2 =b.size();
QByteArray message2(b, blength2);
mavlink1234->RTCMDataUpdate(message2);
break;
#endif
}
else{
QMetaObject::invokeMethod(_linkMgr, "disconnectLink", Q_ARG( LinkInterface*, link ) );
}
return;
}
}
}
RTCM3数据来源是通过RTKLIB的软件将UBX格式转换成RTCM3格式,并且通过TCP发送到QGC,步骤参考我的文章
此外记得添加头文件RTCMMavlink.h
#define myadd
#ifdef myadd
#include "qgroundcontrol/src/GPS/RTCM/RTCMMavlink.h"
#endif
使用的话添加一个TCP连接就好了
应用程序输出