Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5652f391
Commit
5652f391
authored
Sep 18, 2011
by
oberion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed UDP link
parent
ef95a56b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
27 deletions
+71
-27
QGCCore.cc
src/QGCCore.cc
+1
-0
UDPLink.cc
src/comm/UDPLink.cc
+55
-17
UDPLink.h
src/comm/UDPLink.h
+5
-2
CommConfigurationWindow.cc
src/ui/CommConfigurationWindow.cc
+6
-4
MainWindow.cc
src/ui/MainWindow.cc
+4
-4
No files found.
src/QGCCore.cc
View file @
5652f391
...
...
@@ -145,6 +145,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv)
// to make sure that all components are initialized when the
// first messages arrive
UDPLink
*
udpLink
=
new
UDPLink
(
QHostAddress
::
Any
,
14550
);
MainWindow
::
instance
()
->
addLink
(
udpLink
);
// Listen on Multicast-Address 239.255.77.77, Port 14550
//QHostAddress * multicast_udp = new QHostAddress("239.255.77.77");
//UDPLink* udpLink = new UDPLink(*multicast_udp, 14550);
...
...
src/comm/UDPLink.cc
View file @
5652f391
...
...
@@ -40,19 +40,22 @@ This file is part of the QGROUNDCONTROL project
//#include <netinet/in.h>
UDPLink
::
UDPLink
(
QHostAddress
host
,
quint16
port
)
:
socket
(
NULL
)
{
this
->
host
=
host
;
this
->
port
=
port
;
this
->
connectState
=
false
;
// Set unique ID and add link to the list of links
this
->
id
=
getNextLinkId
();
this
->
name
=
tr
(
"UDP Link (port:%1)"
).
arg
(
14550
);
LinkManager
::
instance
()
->
add
(
this
);
this
->
name
=
tr
(
"UDP Link (port:%1)"
).
arg
(
this
->
port
);
emit
nameChanged
(
this
->
name
);
// LinkManager::instance()->add(this);
}
UDPLink
::~
UDPLink
()
{
disconnect
();
this
->
deleteLater
();
}
/**
...
...
@@ -61,23 +64,39 @@ UDPLink::~UDPLink()
**/
void
UDPLink
::
run
()
{
// forever
// {
// QGC::SLEEP::msleep(5000);
// }
exec
();
exec
();
}
void
UDPLink
::
setAddress
(
Q
String
address
)
void
UDPLink
::
setAddress
(
Q
HostAddress
host
)
{
Q_UNUSED
(
address
);
bool
reconnect
(
false
);
if
(
this
->
isConnected
())
{
disconnect
();
reconnect
=
true
;
}
this
->
host
=
host
;
if
(
reconnect
)
{
connect
();
}
}
void
UDPLink
::
setPort
(
int
port
)
{
bool
reconnect
(
false
);
if
(
this
->
isConnected
())
{
disconnect
();
reconnect
=
true
;
}
this
->
port
=
port
;
disconnect
();
connect
();
this
->
name
=
tr
(
"UDP Link (port:%1)"
).
arg
(
this
->
port
);
emit
nameChanged
(
this
->
name
);
if
(
reconnect
)
{
connect
();
}
}
/**
...
...
@@ -104,9 +123,11 @@ void UDPLink::addHost(const QString& host)
}
}
hosts
.
append
(
address
);
this
->
setAddress
(
address
);
//qDebug() << "Address:" << address.toString();
// Set port according to user input
ports
.
append
(
host
.
split
(
":"
).
last
().
toInt
());
this
->
setPort
(
host
.
split
(
":"
).
last
().
toInt
());
}
}
else
...
...
@@ -245,8 +266,14 @@ qint64 UDPLink::bytesAvailable()
**/
bool
UDPLink
::
disconnect
()
{
delete
socket
;
socket
=
NULL
;
this
->
quit
();
this
->
wait
();
if
(
socket
)
{
delete
socket
;
socket
=
NULL
;
}
connectState
=
false
;
...
...
@@ -262,7 +289,19 @@ bool UDPLink::disconnect()
**/
bool
UDPLink
::
connect
()
{
socket
=
new
QUdpSocket
(
this
);
if
(
this
->
isRunning
())
{
this
->
quit
();
this
->
wait
();
}
this
->
hardwareConnect
();
start
(
HighPriority
);
return
true
;
}
bool
UDPLink
::
hardwareConnect
(
void
)
{
socket
=
new
QUdpSocket
();
//Check if we are using a multicast-address
// bool multicast = false;
...
...
@@ -309,11 +348,10 @@ bool UDPLink::connect()
emit
connected
();
connectionStartTime
=
QGC
::
groundTimeUsecs
()
/
1000
;
}
start
(
HighPriority
);
return
connectState
;
return
connectState
;
}
/**
* @brief Check if connection is active.
*
...
...
src/comm/UDPLink.h
View file @
5652f391
...
...
@@ -87,7 +87,7 @@ public:
int
getId
();
public
slots
:
void
setAddress
(
Q
String
address
);
void
setAddress
(
Q
HostAddress
host
);
void
setPort
(
int
port
);
/** @brief Add a new host to broadcast messages to */
void
addHost
(
const
QString
&
host
);
...
...
@@ -128,8 +128,11 @@ protected:
void
setName
(
QString
name
);
private:
bool
hardwareConnect
(
void
);
signals:
//
Signals are defined by LinkInterface
//Signals are defined by LinkInterface
};
...
...
src/ui/CommConfigurationWindow.cc
View file @
5652f391
...
...
@@ -232,14 +232,14 @@ void CommConfigurationWindow::setLinkType(int linktype)
break
;
}
#endif // XBEELINK
/*
case 1:
case
1
:
{
UDPLink
*
udp
=
new
UDPLink
();
tmpLink
=
udp
;
MainWindow
::
instance
()
->
addLink
(
tmpLink
);
break
;
}
*/
#ifdef OPAL_RT
case
3
:
{
...
...
@@ -261,11 +261,13 @@ void CommConfigurationWindow::setLinkType(int linktype)
}
}
// trigger new window
const
int32_t
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
tmpLink
));
const
int32_t
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
QList
<
QAction
*>
actions
=
MainWindow
::
instance
()
->
listLinkMenuActions
();
foreach
(
QAction
*
act
,
actions
)
{
const
int
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
tmpLink
));
const
int
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
if
(
act
->
data
().
toInt
()
==
linkID
)
{
act
->
trigger
();
...
...
src/ui/MainWindow.cc
View file @
5652f391
...
...
@@ -1492,8 +1492,8 @@ void MainWindow::addLink()
// Go fishing for this link's configuration window
QList
<
QAction
*>
actions
=
ui
.
menuNetwork
->
actions
();
const
int
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
));
const
int
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
const
int
32_t
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
));
const
int
32_t
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
foreach
(
QAction
*
act
,
actions
)
{
if
(
act
->
data
().
toInt
()
==
linkID
)
{
// LinkManager::instance()->getLinks().indexOf(link)
...
...
@@ -1517,8 +1517,8 @@ void MainWindow::addLink(LinkInterface *link)
bool
found
(
false
);
const
int
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
));
const
int
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
const
int
32_t
&
linkIndex
(
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
));
const
int
32_t
&
linkID
(
LinkManager
::
instance
()
->
getLinks
()[
linkIndex
]
->
getId
());
foreach
(
QAction
*
act
,
actions
)
{
if
(
act
->
data
().
toInt
()
==
linkID
)
{
// LinkManager::instance()->getLinks().indexOf(link)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment