Skip to content

Commit

Permalink
prevent target_system=0 in toggle safety switch (#3269)
Browse files Browse the repository at this point in the history
a user tried to toggle safety on an antenna tracker and MissionPlanner
sent it to target_system=0, which resulted in toggling safety on a
flying aircraft, causing it to crash
  • Loading branch information
tridge authored Jan 12, 2024
1 parent 2586096 commit c70e8a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion GCSViews/FlightData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,8 +1692,13 @@ private void BUTactiondo_Click(object sender, EventArgs e)
}
if (CMB_action.Text == actions.Toggle_Safety_Switch.ToString())
{
var target_system = (byte)MainV2.comPort.sysidcurrent;
if (target_system == 0) {
log.Info("Not toggling safety on sysid 0");
return;
}
var custom_mode = (MainV2.comPort.MAV.cs.sensors_enabled.motor_control && MainV2.comPort.MAV.cs.sensors_enabled.seen) ? 1u : 0u;
var mode = new MAVLink.mavlink_set_mode_t() { custom_mode = custom_mode, target_system = (byte)MainV2.comPort.sysidcurrent };
var mode = new MAVLink.mavlink_set_mode_t() { custom_mode = custom_mode, target_system = target_system };
MainV2.comPort.setMode(mode, MAVLink.MAV_MODE_FLAG.SAFETY_ARMED);
((Control)sender).Enabled = true;
return;
Expand Down

0 comments on commit c70e8a9

Please sign in to comment.