Browse Source

LinkManager.cc: Add udp link to groundstation position

QGC4.4
Willian Galvani 6 years ago
parent
commit
7c4d31e5af
  1. 22
      src/comm/LinkManager.cc
  2. 2
      src/comm/LinkManager.h

22
src/comm/LinkManager.cc

@ -479,6 +479,27 @@ void LinkManager::_updateAutoConnectLinks(void) @@ -479,6 +479,27 @@ void LinkManager::_updateAutoConnectLinks(void)
createConnectedLink(config);
emit linkConfigurationsChanged();
}
#ifndef __mobile__
// check to see if nmea gps is configured for UDP input, if so, set it up to connect
if (_autoConnectSettings->autoConnectNmeaPort()->cookedValueString() == "UDP Port") {
if (_nmeaSocket.localPort() != _autoConnectSettings->nmeaUdpPort()->rawValue().toUInt()
|| _nmeaSocket.state() != UdpIODevice::BoundState) {
qCDebug(LinkManagerLog) << "Changing port for UDP NMEA stream";
_nmeaSocket.close();
_nmeaSocket.bind(QHostAddress::AnyIPv4, _autoConnectSettings->nmeaUdpPort()->rawValue().toUInt());
_toolbox->qgcPositionManager()->setNmeaSourceDevice(&_nmeaSocket);
}
//close serial port
if (_nmeaPort) {
_nmeaPort->close();
delete _nmeaPort;
_nmeaPort = nullptr;
_nmeaDeviceName = "";
}
} else {
_nmeaSocket.close();
}
#endif
#ifndef NO_SERIAL_LINK
QStringList currentPorts;
@ -513,6 +534,7 @@ void LinkManager::_updateAutoConnectLinks(void) @@ -513,6 +534,7 @@ void LinkManager::_updateAutoConnectLinks(void)
#ifndef NO_SERIAL_LINK
#ifndef __mobile__
// check to see if nmea gps is configured for current Serial port, if so, set it up to connect
if (portInfo.systemLocation().trimmed() == _autoConnectSettings->autoConnectNmeaPort()->cookedValueString()) {
if (portInfo.systemLocation().trimmed() != _nmeaDeviceName) {
_nmeaDeviceName = portInfo.systemLocation().trimmed();

2
src/comm/LinkManager.h

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include "MAVLinkProtocol.h"
#if !defined(__mobile__)
#include "LogReplayLink.h"
#include "UdpIODevice.h"
#endif
#include "QmlObjectListModel.h"
@ -241,6 +242,7 @@ private: @@ -241,6 +242,7 @@ private:
QString _nmeaDeviceName;
QSerialPort* _nmeaPort;
uint32_t _nmeaBaud;
UdpIODevice _nmeaSocket;
#endif
#endif
};

Loading…
Cancel
Save