From 3adb389b7ca0c928e6a7b0a26f5a36d4ff8f4671 Mon Sep 17 00:00:00 2001
From: Julian Oes <julian@oes.ch>
Date: Wed, 17 Jan 2018 06:42:19 -0800
Subject: [PATCH] vmount: don't ignore commands to all component ids

This resolves the case where a gimbal command assembled by
QGroundControl is rejected because the component id is set to 0 (for
all) and the component id of the vehicle is e.g. 1.
---
 src/drivers/vmount/input_mavlink.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/drivers/vmount/input_mavlink.cpp b/src/drivers/vmount/input_mavlink.cpp
index bc88575667..6afdb14789 100644
--- a/src/drivers/vmount/input_mavlink.cpp
+++ b/src/drivers/vmount/input_mavlink.cpp
@@ -230,8 +230,12 @@ int InputMavlinkCmdMount::update_impl(unsigned int timeout_ms, ControlData **con
 			vehicle_command_s vehicle_command;
 			orb_copy(ORB_ID(vehicle_command), _vehicle_command_sub, &vehicle_command);
 
-			// process only if the command is for us
-			if (vehicle_command.target_system != _mav_sys_id || vehicle_command.target_component != _mav_comp_id) {
+			// Process only if the command is for us or for anyone.
+			const bool sysid_correct = (vehicle_command.target_system == _mav_sys_id);
+			const bool compid_correct = ((vehicle_command.target_component == _mav_comp_id) ||
+						     (vehicle_command.target_component == MAV_COMP_ID_ALL));
+
+			if (!sysid_correct || !compid_correct) {
 				return 0;
 			}
 
-- 
GitLab