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)
...
@@ -393,70 +393,65 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
}
}
//
Only count message if UAS exists for this message
//
Increase receive counter
if
(
uas
!=
NULL
)
totalReceiveCounter
[
linkId
]
++
;
{
currReceiveCounter
[
linkId
]
++
;
// Increase receive counter
// Determine what the next expected sequence number is, accounting for
totalReceiveCounter
[
linkId
]
++
;
// never having seen a message for this system/component pair.
currReceiveCounter
[
linkId
]
++
;
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
// And if we didn't encounter that sequence number, record the error
// never having seen a message for this system/component pair.
if
(
message
.
seq
!=
expectedSeq
)
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
// Determine how many messages were skipped
if
(
message
.
seq
!=
expectedSeq
)
int
lostMessages
=
message
.
seq
-
expectedSeq
;
{
// Determine how many messages were skipped
// Out of order messages or wraparound can cause this, but we just ignore these conditions for simplicity
int
lostMessages
=
message
.
seq
-
expectedSeq
;
if
(
lostMessages
<
0
)
{
lostMessages
=
0
;
}
// Out of order messages or wraparound can cause this, but we just ignore these conditions for simplicity
// And log how many were lost for all time and just this timestep
if
(
lostMessages
<
0
)
totalLossCounter
[
linkId
]
+=
lostMessages
;
{
currLossCounter
[
linkId
]
+=
lostMessages
;
lostMessages
=
0
;
}
}
// And log how many were lost for all time and just this timestep
// And update the last sequence number for this system/component pair
totalLossCounter
[
linkId
]
+=
lostMessages
;
lastIndex
[
message
.
sysid
][
message
.
compid
]
=
expectedSeq
;
currLossCounter
[
linkId
]
+=
lostMessages
;
}
// And update the last sequence number for this system/component pair
// Update on every 32th packet
lastIndex
[
message
.
sysid
][
message
.
compid
]
=
expectedSeq
;
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
// The packet is emitted as a whole, as it is only 255 - 261 bytes short
if
((
totalReceiveCounter
[
linkId
]
&
0x1F
)
==
0
)
// kind of inefficient, but no issue for a groundstation pc.
{
// It buys as reentrancy for the whole code over all threads
// Calculate new loss ratio
emit
messageReceived
(
link
,
message
);
// 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
// Multiplex message if enabled
// kind of inefficient, but no issue for a groundstation pc.
if
(
m_multiplexingEnabled
)
// It buys as reentrancy for the whole code over all threads
{
emit
messageReceived
(
link
,
message
);
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinksForProtocol
(
this
);
//
Multiplex message if enabl
ed
//
Emit message on all links that are currently connect
ed
if
(
m_multiplexingEnabled
)
foreach
(
LinkInterface
*
currLink
,
links
)
{
{
// Get all links connected to this unit
// Only forward this message to the other links,
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinksForProtocol
(
this
);
// not the link the message was received on
if
(
currLink
!=
link
)
sendMessage
(
currLink
,
message
,
message
.
sysid
,
message
.
compid
);
// 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
);
}
}
}
}
}
}
}
...
...
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