Skip to content

Commit

Permalink
PrearmStatus: add try-catch around doCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 authored and meee1 committed Feb 14, 2023
1 parent 33a827a commit afa9001
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions Controls/PrearmStatus.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using log4net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -12,6 +14,8 @@ namespace MissionPlanner.Controls
{
public partial class PrearmStatus : Form
{
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

private DateTime lastRequestTime = DateTime.MinValue;
private DateTime searchTime = DateTime.MinValue;
public PrearmStatus()
Expand All @@ -29,15 +33,23 @@ private void requestchecktimer_Tick(object sender, EventArgs e)
{
if (MainV2.comPort.MAV.cs.prearmstatus) return; // Don't request prearm checks if we are ready to arm

lastRequestTime = DateTime.Now;
try
{
// Request prearm checks to be performed
MainV2.comPort.doCommand(
(byte)MainV2.comPort.sysidcurrent, (byte)MainV2.comPort.compidcurrent,
MAVLink.MAV_CMD.RUN_PREARM_CHECKS,
0, 0, 0, 0, 0, 0, 0,
false // don't require ack
);

lastRequestTime = DateTime.Now;

// Request prearm checks to be performed
MainV2.comPort.doCommand(
(byte)MainV2.comPort.sysidcurrent, (byte)MainV2.comPort.compidcurrent,
MAVLink.MAV_CMD.RUN_PREARM_CHECKS,
0, 0, 0, 0, 0, 0, 0,
false // don't require ack
);
}
catch (Exception ex)
{
log.Error(ex.Message);
}
}

private void updatetexttimer_Tick(object sender, EventArgs e)
Expand Down

0 comments on commit afa9001

Please sign in to comment.