From 82225de6faf398f17410dfb15ab74d4bdcc301d4 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sun, 14 Sep 2014 17:50:35 +0900 Subject: [PATCH] Plane: allow GCS to turn safety switch on/off --- ArduPlane/GCS_Mavlink.pde | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ArduPlane/GCS_Mavlink.pde b/ArduPlane/GCS_Mavlink.pde index fee54dbf3e..ae4fdd0ffc 100644 --- a/ArduPlane/GCS_Mavlink.pde +++ b/ArduPlane/GCS_Mavlink.pde @@ -1156,6 +1156,19 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg) break; } + // 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(); + } else if (packet.custom_mode == 1) { + // turn safety on (no pwm outputs to the motors) + hal.rcout->force_safety_on(); + } + break; + } + + // check if we are setting the flight mode if (!(packet.base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED)) { // we ignore base_mode as there is no sane way to map // from that bitmap to a APM flight mode. We rely on