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
c2009e85
Commit
c2009e85
authored
Aug 05, 2014
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also show MAVLink traffic without a valid system connected
parent
c78ad877
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
53 deletions
+48
-53
MAVLinkProtocol.cc
src/comm/MAVLinkProtocol.cc
+48
-53
No files found.
src/comm/MAVLinkProtocol.cc
View file @
c2009e85
...
...
@@ -393,70 +393,65 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
}
//
Only count message if UAS exists for this message
if
(
uas
!=
NULL
)
{
//
Increase receive counter
totalReceiveCounter
[
linkId
]
++
;
currReceiveCounter
[
linkId
]
++
;
// Increase receive counter
totalReceiveCounter
[
linkId
]
++
;
currReceiveCounter
[
linkId
]
++
;
// Determine what the next expected sequence number is, accounting for
// never having seen a message for this system/component pair.
int
lastSeq
=
lastIndex
[
message
.
sysid
][
message
.
compid
];
int
expectedSeq
=
(
lastSeq
==
-
1
)
?
message
.
seq
:
(
lastSeq
+
1
);
// Determine what the next expected sequence number is, accounting for
// never having seen a message for this system/component pair.
int
lastSeq
=
lastIndex
[
message
.
sysid
][
message
.
compid
];
int
expectedSeq
=
(
lastSeq
==
-
1
)
?
message
.
seq
:
(
lastSeq
+
1
);
// And if we didn't encounter that sequence number, record the error
if
(
message
.
seq
!=
expectedSeq
)
{
// And if we didn't encounter that sequence number, record the error
if
(
message
.
seq
!=
expectedSeq
)
{
// Determine how many messages were skipped
int
lostMessages
=
message
.
seq
-
expectedSeq
;
// Determine how many messages were skipped
int
lostMessages
=
message
.
seq
-
expectedSeq
;
// Out of order messages or wraparound can cause this, but we just ignore these conditions for simplicity
if
(
lostMessages
<
0
)
{
lostMessages
=
0
;
}
// Out of order messages or wraparound can cause this, but we just ignore these conditions for simplicity
if
(
lostMessages
<
0
)
{
lostMessages
=
0
;
}
// And log how many were lost for all time and just this timestep
totalLossCounter
[
linkId
]
+=
lostMessages
;
currLossCounter
[
linkId
]
+=
lostMessages
;
}
// And log how many were lost for all time and just this timestep
totalLossCounter
[
linkId
]
+=
lostMessages
;
currLossCounter
[
linkId
]
+=
lostMessages
;
}
// And update the last sequence number for this system/component pair
lastIndex
[
message
.
sysid
][
message
.
compid
]
=
expectedSeq
;
// And update the last sequence number for this system/component pair
lastIndex
[
message
.
sysid
][
message
.
compid
]
=
expectedSeq
;
// Update on every 32th packet
if
((
totalReceiveCounter
[
linkId
]
&
0x1F
)
==
0
)
{
// Calculate new loss ratio
// Receive loss
float
receiveLoss
=
(
double
)
currLossCounter
[
linkId
]
/
(
double
)(
currReceiveCounter
[
linkId
]
+
currLossCounter
[
linkId
]);
receiveLoss
*=
100.0
f
;
currLossCounter
[
linkId
]
=
0
;
currReceiveCounter
[
linkId
]
=
0
;
emit
receiveLossChanged
(
message
.
sysid
,
receiveLoss
);
}
// Update on every 32th packet
if
((
totalReceiveCounter
[
linkId
]
&
0x1F
)
==
0
)
{
// Calculate new loss ratio
// Receive loss
float
receiveLoss
=
(
double
)
currLossCounter
[
linkId
]
/
(
double
)(
currReceiveCounter
[
linkId
]
+
currLossCounter
[
linkId
]);
receiveLoss
*=
100.0
f
;
currLossCounter
[
linkId
]
=
0
;
currReceiveCounter
[
linkId
]
=
0
;
emit
receiveLossChanged
(
message
.
sysid
,
receiveLoss
);
}
// The packet is emitted as a whole, as it is only 255 - 261 bytes short
// kind of inefficient, but no issue for a groundstation pc.
// It buys as reentrancy for the whole code over all threads
emit
messageReceived
(
link
,
message
);
// The packet is emitted as a whole, as it is only 255 - 261 bytes short
// kind of inefficient, but no issue for a groundstation pc.
// It buys as reentrancy for the whole code over all threads
emit
messageReceived
(
link
,
message
);
// Multiplex message if enabled
if
(
m_multiplexingEnabled
)
{
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinksForProtocol
(
this
);
//
Multiplex message if enabl
ed
if
(
m_multiplexingEnabled
)
//
Emit message on all links that are currently connect
ed
foreach
(
LinkInterface
*
currLink
,
links
)
{
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinksForProtocol
(
this
);
// Emit message on all links that are currently connected
foreach
(
LinkInterface
*
currLink
,
links
)
{
// Only forward this message to the other links,
// not the link the message was received on
if
(
currLink
!=
link
)
sendMessage
(
currLink
,
message
,
message
.
sysid
,
message
.
compid
);
}
// Only forward this message to the other links,
// not the link the message was received on
if
(
currLink
!=
link
)
sendMessage
(
currLink
,
message
,
message
.
sysid
,
message
.
compid
);
}
}
}
...
...
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