From 7c4d31e5af4ed18d3e3bcb54149a9e2d577713cb Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Wed, 5 Dec 2018 10:20:18 -0200 Subject: [PATCH] LinkManager.cc: Add udp link to groundstation position --- src/comm/LinkManager.cc | 22 ++++++++++++++++++++++ src/comm/LinkManager.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 036441a4b..6f511c822 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -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) #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(); diff --git a/src/comm/LinkManager.h b/src/comm/LinkManager.h index f09360142..8322e1c6f 100644 --- a/src/comm/LinkManager.h +++ b/src/comm/LinkManager.h @@ -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: QString _nmeaDeviceName; QSerialPort* _nmeaPort; uint32_t _nmeaBaud; + UdpIODevice _nmeaSocket; #endif #endif }; -- 2.22.0