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
997e7626
Commit
997e7626
authored
May 03, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch MockLink to Mavlink 2.0
parent
59a15139
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
36 deletions
+65
-36
LinkManager.cc
src/comm/LinkManager.cc
+28
-19
LinkManager.h
src/comm/LinkManager.h
+7
-0
MockLink.cc
src/comm/MockLink.cc
+29
-17
MockLink.h
src/comm/MockLink.h
+1
-0
No files found.
src/comm/LinkManager.cc
View file @
997e7626
...
...
@@ -171,25 +171,12 @@ void LinkManager::_addLink(LinkInterface* link)
}
if
(
!
containsLink
(
link
))
{
bool
channelSet
=
false
;
// Find a mavlink channel to use for this link, Channel 0 is reserved for internal use.
for
(
int
i
=
1
;
i
<
32
;
i
++
)
{
if
(
!
(
_mavlinkChannelsUsedBitMask
&
1
<<
i
))
{
mavlink_reset_channel_status
(
i
);
link
->
_setMavlinkChannel
(
i
);
// Start the channel on Mav 1 protocol
mavlink_status_t
*
mavlinkStatus
=
mavlink_get_channel_status
(
i
);
mavlinkStatus
->
flags
=
mavlink_get_channel_status
(
i
)
->
flags
|
MAVLINK_STATUS_FLAG_OUT_MAVLINK1
;
qDebug
()
<<
"LinkManager mavlinkStatus:channel:flags"
<<
mavlinkStatus
<<
i
<<
mavlinkStatus
->
flags
;
_mavlinkChannelsUsedBitMask
|=
1
<<
i
;
channelSet
=
true
;
break
;
}
}
if
(
!
channelSet
)
{
int
mavlinkChannel
=
_reserveMavlinkChannel
();
if
(
mavlinkChannel
!=
0
)
{
link
->
_setMavlinkChannel
(
mavlinkChannel
);
}
else
{
qWarning
()
<<
"Ran out of mavlink channels"
;
return
;
}
_sharedLinks
.
append
(
SharedLinkInterfacePointer
(
link
));
...
...
@@ -260,7 +247,7 @@ void LinkManager::_deleteLink(LinkInterface* link)
}
// Free up the mavlink channel associated with this link
_
mavlinkChannelsUsedBitMask
&=
~
(
1
<<
link
->
mavlinkChannel
());
_
freeMavlinkChannel
(
link
->
mavlinkChannel
());
for
(
int
i
=
0
;
i
<
_sharedLinks
.
count
();
i
++
)
{
if
(
_sharedLinks
[
i
].
data
()
==
link
)
{
...
...
@@ -925,3 +912,25 @@ void LinkManager::startAutoConnectedLinks(void)
createConnectedLink
(
conf
);
}
}
int
LinkManager
::
_reserveMavlinkChannel
(
void
)
{
// Find a mavlink channel to use for this link, Channel 0 is reserved for internal use.
for
(
int
mavlinkChannel
=
1
;
mavlinkChannel
<
32
;
mavlinkChannel
++
)
{
if
(
!
(
_mavlinkChannelsUsedBitMask
&
1
<<
mavlinkChannel
))
{
mavlink_reset_channel_status
(
mavlinkChannel
);
// Start the channel on Mav 1 protocol
mavlink_status_t
*
mavlinkStatus
=
mavlink_get_channel_status
(
mavlinkChannel
);
mavlinkStatus
->
flags
|=
MAVLINK_STATUS_FLAG_OUT_MAVLINK1
;
_mavlinkChannelsUsedBitMask
|=
1
<<
mavlinkChannel
;
return
mavlinkChannel
;
}
}
return
0
;
// All channels reserved
}
void
LinkManager
::
_freeMavlinkChannel
(
int
channel
)
{
_mavlinkChannelsUsedBitMask
&=
~
(
1
<<
channel
);
}
src/comm/LinkManager.h
View file @
997e7626
...
...
@@ -153,6 +153,13 @@ public:
void
startAutoConnectedLinks
(
void
);
/// Reserves a mavlink channel for use
/// @return Mavlink channel index, 0 for no channels available
int
_reserveMavlinkChannel
(
void
);
/// Free the specified mavlink channel for re-use
void
_freeMavlinkChannel
(
int
channel
);
static
const
char
*
settingsGroup
;
signals:
...
...
src/comm/MockLink.cc
View file @
997e7626
This diff is collapsed.
Click to expand it.
src/comm/MockLink.h
View file @
997e7626
...
...
@@ -199,6 +199,7 @@ private:
QString
_name
;
bool
_connected
;
int
_mavlinkChannel
;
uint8_t
_vehicleSystemId
;
uint8_t
_vehicleComponentId
;
...
...
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