Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
ebeb9eba
Commit
ebeb9eba
authored
9 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up target system handling for some commands
parent
a8e3194d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/mavlink/mavlink_receiver.cpp
+24
-15
24 additions, 15 deletions
src/modules/mavlink/mavlink_receiver.cpp
src/modules/mavlink/mavlink_receiver.h
+2
-0
2 additions, 0 deletions
src/modules/mavlink/mavlink_receiver.h
with
26 additions
and
15 deletions
src/modules/mavlink/mavlink_receiver.cpp
+
24
−
15
View file @
ebeb9eba
...
...
@@ -279,29 +279,37 @@ MavlinkReceiver::handle_message(mavlink_message_t *msg)
_mavlink
->
set_has_received_messages
(
true
);
}
void
MavlinkReceiver
::
handle_message_command_long
(
mavlink_message_t
*
msg
)
bool
MavlinkReceiver
::
evaluate_target_ok
(
int
command
,
int
target_system
,
int
target_component
)
{
/* command */
mavlink_command_long_t
cmd_mavlink
;
mavlink_msg_command_long_decode
(
msg
,
&
cmd_mavlink
);
/* evaluate if this system should accept this command */
bool
target_ok
;
switch
(
cmd_mavlink
.
command
)
{
bool
target_ok
=
false
;
switch
(
command
)
{
case
MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES
:
/* broadcast */
target_ok
=
(
cmd_mavlink
.
target_system
==
0
);
/* broadcast
and ignore component
*/
target_ok
=
(
target_system
==
0
)
||
(
target_system
==
mavlink_system
.
sysid
);
break
;
default:
target_ok
=
(
cmd_mavlink
.
target_system
==
mavlink_system
.
sysid
);
target_ok
=
(
target_system
==
mavlink_system
.
sysid
)
&&
((
target_component
==
mavlink_system
.
compid
)
||
(
target_component
==
MAV_COMP_ID_ALL
));
break
;
}
if
(
target_ok
&&
((
cmd_mavlink
.
target_component
==
mavlink_system
.
compid
)
||
(
cmd_mavlink
.
target_component
==
MAV_COMP_ID_ALL
)))
{
return
target_ok
;
}
void
MavlinkReceiver
::
handle_message_command_long
(
mavlink_message_t
*
msg
)
{
/* command */
mavlink_command_long_t
cmd_mavlink
;
mavlink_msg_command_long_decode
(
msg
,
&
cmd_mavlink
);
bool
target_ok
=
evaluate_target_ok
(
cmd_mavlink
.
command
,
cmd_mavlink
.
target_system
,
cmd_mavlink
.
target_component
);
if
(
target_ok
)
{
//check for MAVLINK terminate command
if
(
cmd_mavlink
.
command
==
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN
&&
((
int
)
cmd_mavlink
.
param1
)
==
3
)
{
/* This is the link shutdown command, terminate mavlink */
...
...
@@ -362,8 +370,9 @@ MavlinkReceiver::handle_message_command_int(mavlink_message_t *msg)
mavlink_command_int_t
cmd_mavlink
;
mavlink_msg_command_int_decode
(
msg
,
&
cmd_mavlink
);
if
(
cmd_mavlink
.
target_system
==
mavlink_system
.
sysid
&&
((
cmd_mavlink
.
target_component
==
mavlink_system
.
compid
)
||
(
cmd_mavlink
.
target_component
==
MAV_COMP_ID_ALL
)))
{
bool
target_ok
=
evaluate_target_ok
(
cmd_mavlink
.
command
,
cmd_mavlink
.
target_system
,
cmd_mavlink
.
target_component
);
if
(
target_ok
)
{
//check for MAVLINK terminate command
if
(
cmd_mavlink
.
command
==
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN
&&
((
int
)
cmd_mavlink
.
param1
)
==
3
)
{
/* This is the link shutdown command, terminate mavlink */
...
...
This diff is collapsed.
Click to expand it.
src/modules/mavlink/mavlink_receiver.h
+
2
−
0
View file @
ebeb9eba
...
...
@@ -161,6 +161,8 @@ private:
*/
int
decode_switch_pos_n
(
uint16_t
buttons
,
unsigned
sw
);
bool
evaluate_target_ok
(
int
command
,
int
target_system
,
int
target_component
);
mavlink_status_t
status
;
struct
vehicle_local_position_s
hil_local_pos
;
struct
vehicle_land_detected_s
hil_land_detector
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment