Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion GCSViews/FlightData.cs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add a variable and cast the sysidcurrent to byte
if (MainV2.comPort.sysidcurrent == 0).... is just fine
also this check must be added to temp.cs at line 1188 (CTRL-F screen).
Instead of logging, a messagebox would be better to let the user know that the button did nothing...
(CustomMessageBox.Show("Not toggling safety on sysid 0")

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