From 2efeb768e0178de8ace4392a59f02b9890a66360 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sun, 14 Sep 2014 17:28:37 +0900 Subject: [PATCH] Copter: allow GCS to turn safety switch on/off --- ArduCopter/GCS_Mavlink.pde | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ArduCopter/GCS_Mavlink.pde b/ArduCopter/GCS_Mavlink.pde index c758683c00..bfe017f269 100644 --- a/ArduCopter/GCS_Mavlink.pde +++ b/ArduCopter/GCS_Mavlink.pde @@ -898,6 +898,20 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg) } } + // set the safety switch position + if (packet.base_mode & MAV_MODE_FLAG_DECODE_POSITION_SAFETY) { + if (packet.custom_mode == 0) { + // turn safety off (pwm outputs flow to the motors) + hal.rcout->force_safety_off(); + result = MAV_RESULT_ACCEPTED; + } else if (packet.custom_mode == 1) { + // turn safety on (no pwm outputs to the motors) + if (hal.rcout->force_safety_on()) { + result = MAV_RESULT_ACCEPTED; + } + } + } + // send ACK or NAK mavlink_msg_command_ack_send_buf(msg, chan, MAVLINK_MSG_ID_SET_MODE, result); break;