diff --git a/Common.cs b/Common.cs index 408c07a893..03db903fca 100644 --- a/Common.cs +++ b/Common.cs @@ -103,11 +103,11 @@ enum PX4_CUSTOM_SUB_MODE_AUTO PX4_CUSTOM_SUB_MODE_AUTO_RTGS } - public static List> getModesList(CurrentState cs) + public static List> getModesList(MainV2.Firmwares firmware) { log.Info("getModesList Called"); - if (cs.firmware == MainV2.Firmwares.PX4) + if (firmware == MainV2.Firmwares.PX4) { /* union px4_custom_mode { @@ -158,10 +158,10 @@ struct { return temp; } - else if (cs.firmware == MainV2.Firmwares.ArduPlane) + else if (firmware == MainV2.Firmwares.ArduPlane) { var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1", - cs.firmware.ToString()); + firmware.ToString()); flightModes.Add(new KeyValuePair(16, "INITIALISING")); flightModes.Add(new KeyValuePair(17, "QStabilize")); @@ -172,25 +172,25 @@ struct { return flightModes; } - else if (cs.firmware == MainV2.Firmwares.Ateryx) + else if (firmware == MainV2.Firmwares.Ateryx) { var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1", - cs.firmware.ToString()); //same as apm + firmware.ToString()); //same as apm return flightModes; } - else if (cs.firmware == MainV2.Firmwares.ArduCopter2) + else if (firmware == MainV2.Firmwares.ArduCopter2) { var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1", - cs.firmware.ToString()); + firmware.ToString()); return flightModes; } - else if (cs.firmware == MainV2.Firmwares.ArduRover) + else if (firmware == MainV2.Firmwares.ArduRover) { var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("MODE1", - cs.firmware.ToString()); + firmware.ToString()); return flightModes; } - else if (cs.firmware == MainV2.Firmwares.ArduTracker) + else if (firmware == MainV2.Firmwares.ArduTracker) { var temp = new List>(); temp.Add(new KeyValuePair(0, "MANUAL")); diff --git a/CurrentState.cs b/CurrentState.cs index f34785276f..cd5357f3e9 100644 --- a/CurrentState.cs +++ b/CurrentState.cs @@ -1602,7 +1602,7 @@ public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool up if ((highlatency.base_mode & (byte) MAVLink.MAV_MODE_FLAG.CUSTOM_MODE_ENABLED) != 0) { - List> modelist = Common.getModesList(this); + List> modelist = Common.getModesList(this.firmware); if (modelist != null) { @@ -1890,7 +1890,7 @@ public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool up // prevent running thsi unless we have to if (_mode != hb.custom_mode) { - List> modelist = Common.getModesList(this); + List> modelist = Common.getModesList(this.firmware); if (modelist != null) { diff --git a/ExtLibs/Controls/BackstageView/BackstageView.cs b/ExtLibs/Controls/BackstageView/BackstageView.cs index 2bf76215d2..4ea150701c 100644 --- a/ExtLibs/Controls/BackstageView/BackstageView.cs +++ b/ExtLibs/Controls/BackstageView/BackstageView.cs @@ -443,8 +443,6 @@ public void ActivatePage(BackstageViewPage associatedPage) { if (associatedPage == null) { - if (associatedPage.Page == null) - return; if (_activePage == null) DrawMenu(null, true); return; diff --git a/ExtLibs/Controls/MainSwitcher.cs b/ExtLibs/Controls/MainSwitcher.cs index ca35416ea1..9bb3c20bc7 100644 --- a/ExtLibs/Controls/MainSwitcher.cs +++ b/ExtLibs/Controls/MainSwitcher.cs @@ -241,8 +241,8 @@ public void Dispose() { try { - Console.WriteLine("MainSwitcher dispose " + item.Name); - if (item != null && item.Control != null) + Console.WriteLine("MainSwitcher dispose " + item?.Name); + if (item?.Control != null) { item.Control.Close(); item.Control.Dispose(); diff --git a/ExtLibs/Controls/MyUserControl.cs b/ExtLibs/Controls/MyUserControl.cs index 4413f8dc51..a675015a10 100644 --- a/ExtLibs/Controls/MyUserControl.cs +++ b/ExtLibs/Controls/MyUserControl.cs @@ -9,8 +9,8 @@ namespace System.Windows.Forms /// [ComVisible(true)] public class MyUserControl : System.Windows.Forms.UserControl - { - private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + { + private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// implement an on closing event to tidy up enviroment. /// Using preedefined refrence as can easerly change between form and user control this way. diff --git a/Log/BinaryLog.cs b/ExtLibs/Utilities/BinaryLog.cs similarity index 92% rename from Log/BinaryLog.cs rename to ExtLibs/Utilities/BinaryLog.cs index 0cce0c5d97..b9a9f71cec 100644 --- a/Log/BinaryLog.cs +++ b/ExtLibs/Utilities/BinaryLog.cs @@ -5,11 +5,9 @@ using System.Text; using System.IO; using System.Runtime.InteropServices; -using MissionPlanner.Controls; using uint8_t = System.Byte; -using MissionPlanner.Utilities; -namespace MissionPlanner.Log +namespace MissionPlanner.Utilities { /// /// Convert a binary log to an assci log @@ -51,60 +49,25 @@ public UnionArray(byte[] bytes) [FieldOffset(0)] public short[] Shorts; - } - - private IProgressReporterDialogue prd; + } + private string inputfn; - private string outputfn; - private event convertProgress convertstatus; + private string outputfn; + object locker = new object(); - - private delegate void convertProgress(IProgressReporterDialogue prd, float progress); - + Dictionary logformat = new Dictionary(); - public static void ConvertBin(string inputfn, string outputfn, bool showui = true) - { - if (!showui) - { - new BinaryLog().ConvertBini(inputfn, outputfn, false); - return; - } - - new BinaryLog().doUI(inputfn, outputfn, true); - } - - void doUI(string inputfn, string outputfn, bool showui = true) - { - this.inputfn = inputfn; - this.outputfn = outputfn; - - prd = new ProgressReporterDialogue(); - - prd.DoWork += prd_DoWork; - - prd.UpdateProgressAndStatus(-1, Strings.Converting_bin_to_log); + public static event getFlightMode onFlightMode; - this.convertstatus += BinaryLog_convertstatus; + public delegate string getFlightMode(string firmware, int modeno); - ThemeManager.ApplyThemeTo(prd); - - prd.RunBackgroundOperationAsync(); - - prd.Dispose(); - } - - void BinaryLog_convertstatus(IProgressReporterDialogue prd, float progress) - { - prd.UpdateProgressAndStatus((int) progress, Strings.Converting_bin_to_log); - } - - void prd_DoWork(object sender, ProgressWorkerEventArgs e, object passdata = null) + public static void ConvertBin(string inputfn, string outputfn, Action progress = null) { - this.ConvertBini(inputfn, outputfn, true); + new BinaryLog().ConvertBini(inputfn, outputfn, progress); } - void ConvertBini(string inputfn, string outputfn, bool showui = true) + void ConvertBini(string inputfn, string outputfn, Action progress = null) { using (var stream = File.Open(outputfn, FileMode.Create)) { @@ -116,8 +79,8 @@ void ConvertBini(string inputfn, string outputfn, bool showui = true) { if (displaytimer.Second != DateTime.Now.Second) { - if (convertstatus != null && prd != null) - convertstatus(prd, (br.BaseStream.Position/(float) br.BaseStream.Length)*100); + if (progress != null) + progress((int) ((br.BaseStream.Position / (float) br.BaseStream.Length) * 100)); Console.WriteLine("ConvertBin " + (br.BaseStream.Position/(float) br.BaseStream.Length)*100); displaytimer = DateTime.Now; @@ -129,6 +92,8 @@ void ConvertBini(string inputfn, string outputfn, bool showui = true) } } + private string _firmware = ""; + public string ReadMessage(Stream br) { lock (locker) @@ -171,25 +136,25 @@ public string ReadMessage(Stream br) if (line.Contains("PARM, RATE_RLL_P") || line.Contains("ArduCopter") || line.Contains("Copter")) { - MainV2.comPort.MAV.cs.firmware = MainV2.Firmwares.ArduCopter2; + _firmware = "ArduCopter2"; } else if ((line.Contains("PARM, H_SWASH_PLATE")) || line.Contains("ArduCopter")) { - MainV2.comPort.MAV.cs.firmware = MainV2.Firmwares.ArduCopter2; + _firmware = "ArduCopter2"; } else if (line.Contains("PARM, PTCH2SRV_P") || line.Contains("ArduPlane") || line.Contains("Plane")) { - MainV2.comPort.MAV.cs.firmware = MainV2.Firmwares.ArduPlane; + _firmware ="ArduPlane"; } else if (line.Contains("PARM, SKID_STEER_OUT") || line.Contains("ArduRover") || line.Contains("Rover")) { - MainV2.comPort.MAV.cs.firmware = MainV2.Firmwares.ArduRover; + _firmware = "ArduRover"; } else if (line.Contains("AntennaTracker") || line.Contains("Tracker")) { - MainV2.comPort.MAV.cs.firmware = MainV2.Firmwares.ArduTracker; + _firmware = "ArduTracker"; } return line; @@ -815,18 +780,8 @@ string ProcessMessage(byte[] message, string name, string format) break; case 'M': int modeno = message[offset]; - var modes = Common.getModesList(MainV2.comPort.MAV.cs); - string currentmode = ""; - - foreach (var mode in modes) - { - if (mode.Key == modeno) - { - currentmode = mode.Value; - break; - } - } - + var mode = onFlightMode?.Invoke(_firmware, modeno); + string currentmode = mode == null ? modeno.ToString() : mode; line.Append(", " + currentmode); offset++; break; diff --git a/Log/CollectionBuffer.cs b/ExtLibs/Utilities/CollectionBuffer.cs similarity index 95% rename from Log/CollectionBuffer.cs rename to ExtLibs/Utilities/CollectionBuffer.cs index 2679edaeb1..251cfef34d 100644 --- a/Log/CollectionBuffer.cs +++ b/ExtLibs/Utilities/CollectionBuffer.cs @@ -4,8 +4,9 @@ using System.IO; using System.Linq; using System.Text; +using MissionPlanner.Utilities; -namespace MissionPlanner.Log +namespace MissionPlanner.Utilities { public class CollectionBuffer : IEnumerable, IDisposable { diff --git a/Log/DFLog.cs b/ExtLibs/Utilities/DFLog.cs similarity index 95% rename from Log/DFLog.cs rename to ExtLibs/Utilities/DFLog.cs index 347cea3309..1e01ca0a0e 100644 --- a/Log/DFLog.cs +++ b/ExtLibs/Utilities/DFLog.cs @@ -6,7 +6,7 @@ using System.Text; using log4net; -namespace MissionPlanner.Log +namespace MissionPlanner.Utilities { /// /// read log and extract log @@ -33,7 +33,7 @@ public struct DFItem public int timems; public int lineno; - internal DFLog parent; + public DFLog parent; public string this[string item] { @@ -233,7 +233,6 @@ public List ReadLog(Stream fn) catch (OutOfMemoryException ex) { log.Error(ex); - CustomMessageBox.Show("out of memory"); return answer; } catch @@ -504,7 +503,7 @@ public static DateTime gpsTimeToTime(int week, double sec) public int FindMessageOffset(string linetype, string find) { if (logformat.ContainsKey(linetype.ToUpper())) - return Log.DFLog.FindInArray(logformat[linetype].FieldNames, find); + return FindInArray(logformat[linetype].FieldNames, find); return -1; } diff --git a/Log/DashWare.cs b/ExtLibs/Utilities/DashWare.cs similarity index 95% rename from Log/DashWare.cs rename to ExtLibs/Utilities/DashWare.cs index 981cc38858..1977c8956c 100644 --- a/Log/DashWare.cs +++ b/ExtLibs/Utilities/DashWare.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using MissionPlanner.Utilities; namespace MissionPlanner.Log { diff --git a/ExtLibs/Utilities/Privacy.cs b/ExtLibs/Utilities/Privacy.cs new file mode 100644 index 0000000000..39c77a8d67 --- /dev/null +++ b/ExtLibs/Utilities/Privacy.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using MissionPlanner.Comms; + +namespace MissionPlanner.Utilities +{ + public class Privacy + { + public static void anonymise(string logfile, string outputfile) + { + //LOG + using (CollectionBuffer col = new CollectionBuffer(File.OpenRead(logfile))) + using (var outfilestream = File.Open(outputfile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) + { + foreach (var dfItem in col.GetEnumeratorTypeAll()) + { + if (dfItem.msgtype.StartsWith("GPS")) + continue; + if (dfItem.msgtype.StartsWith("CMD")) + continue; + if (dfItem.msgtype.StartsWith("CAM")) + continue; + if (dfItem.msgtype.StartsWith("TRIG")) + continue; + if (dfItem.msgtype.StartsWith("AHR2")) + continue; + if (dfItem.msgtype.StartsWith("POS")) + continue; + if (dfItem.msgtype.StartsWith("TERR")) + continue; + if (dfItem.msgtype.StartsWith("SBFE")) + continue; + if (dfItem.msgtype.StartsWith("ORGN")) + continue; + + var str = String.Join(",", dfItem.items); + outfilestream.Write(ASCIIEncoding.ASCII.GetBytes(str), 0, str.Length); + } + } + + return; + // TLOG + Comms.CommsFile tlogFile = new CommsFile(); + tlogFile.Open(logfile); + + using (var stream = new CommsStream(tlogFile, tlogFile.BytesToRead)) + using (var outfilestream = File.Open(outputfile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) + { + MAVLink.MavlinkParse parse = new MAVLink.MavlinkParse(); + + double lat = 0; + double lng = 0; + + while (stream.Position < stream.Length) + { + var packet = parse.ReadPacket(stream); + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.GLOBAL_POSITION_INT) + { + packet.ToStructure(); + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.POSITION_TARGET_GLOBAL_INT) + { + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.SET_HOME_POSITION) + { + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.HOME_POSITION) + { + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.SET_POSITION_TARGET_GLOBAL_INT) + { + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.LOCAL_POSITION_NED) + { + } + + if (packet.msgid == (uint) MAVLink.MAVLINK_MSG_ID.COMMAND_LONG) + { + } + + if (packet.msgid == (uint)MAVLink.MAVLINK_MSG_ID.MISSION_ITEM) + { + } + + if (packet.msgid == (uint)MAVLink.MAVLINK_MSG_ID.MISSION_ITEM_INT) + { + } + + byte[] datearray = + BitConverter.GetBytes( + (UInt64) ((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds * 1000)); + Array.Reverse(datearray); + outfilestream.Write(datearray, 0, datearray.Length); + outfilestream.Write(packet.buffer, 0, packet.Length); + } + } + } + } +} diff --git a/ExtLibs/Utilities/Vector3.cs b/ExtLibs/Utilities/Vector3.cs index 31eee8ce03..6f03f519b7 100644 --- a/ExtLibs/Utilities/Vector3.cs +++ b/ExtLibs/Utilities/Vector3.cs @@ -33,6 +33,24 @@ public class Vector3 where T: struct public T y; public T z; + public T X + { + get { return x; } + set { x = value; } + } + + public T Y + { + get { return y; } + set { y = value; } + } + + public T Z + { + get { return z; } + set { z = value; } + } + public Vector3(T x, T y, T z) { this.x = x; diff --git a/GCSViews/ConfigurationView/ConfigFlightModes.cs b/GCSViews/ConfigurationView/ConfigFlightModes.cs index 5dc938ea6c..fa8e30de4e 100644 --- a/GCSViews/ConfigurationView/ConfigFlightModes.cs +++ b/GCSViews/ConfigurationView/ConfigFlightModes.cs @@ -403,7 +403,7 @@ private void BUT_SaveModes_Click(object sender, EventArgs e) private void updateDropDown(ComboBox ctl, string param) { - ctl.DataSource = Common.getModesList(MainV2.comPort.MAV.cs); + ctl.DataSource = Common.getModesList(MainV2.comPort.MAV.cs.firmware); ctl.DisplayMember = "Value"; ctl.ValueMember = "Key"; } diff --git a/GCSViews/FlightData.cs b/GCSViews/FlightData.cs index 7ef05e767f..b2560b1dd8 100644 --- a/GCSViews/FlightData.cs +++ b/GCSViews/FlightData.cs @@ -266,7 +266,7 @@ public FlightData() CMB_action.DataSource = list; - CMB_modes.DataSource = Common.getModesList(MainV2.comPort.MAV.cs); + CMB_modes.DataSource = Common.getModesList(MainV2.comPort.MAV.cs.firmware); CMB_modes.ValueMember = "Key"; CMB_modes.DisplayMember = "Value"; @@ -2583,7 +2583,7 @@ private void BUT_joystick_Click(object sender, EventArgs e) private void CMB_modes_Click(object sender, EventArgs e) { - CMB_modes.DataSource = Common.getModesList(MainV2.comPort.MAV.cs); + CMB_modes.DataSource = Common.getModesList(MainV2.comPort.MAV.cs.firmware); CMB_modes.ValueMember = "Key"; CMB_modes.DisplayMember = "Value"; } diff --git a/Joystick/Joy_ChangeMode.cs b/Joystick/Joy_ChangeMode.cs index cefeb36396..581ed10649 100644 --- a/Joystick/Joy_ChangeMode.cs +++ b/Joystick/Joy_ChangeMode.cs @@ -19,7 +19,7 @@ public Joy_ChangeMode(string name) this.Tag = name; - comboBox1.DataSource = Common.getModesList(MainV2.comPort.MAV.cs); + comboBox1.DataSource = Common.getModesList(MainV2.comPort.MAV.cs.firmware); comboBox1.ValueMember = "Key"; comboBox1.DisplayMember = "Value"; diff --git a/Log/LogDownload.cs b/Log/LogDownload.cs index 17e93b2d88..14c8086d8a 100644 --- a/Log/LogDownload.cs +++ b/Log/LogDownload.cs @@ -559,14 +559,13 @@ private void BUT_redokml_Click(object sender, EventArgs e) LogOutput lo = new LogOutput(); try { - TextReader tr = new StreamReader(logfile); - - while (tr.Peek() != -1) + using (TextReader tr = new StreamReader(logfile)) { - lo.processLine(tr.ReadLine()); + while (tr.Peek() != -1) + { + lo.processLine(tr.ReadLine()); + } } - - tr.Close(); } catch (Exception ex) { diff --git a/Log/LogDownloadMavLink.cs b/Log/LogDownloadMavLink.cs index 6d458d1310..99007c3332 100644 --- a/Log/LogDownloadMavLink.cs +++ b/Log/LogDownloadMavLink.cs @@ -498,14 +498,13 @@ private void BUT_redokml_Click(object sender, EventArgs e) LogOutput lo = new LogOutput(); try { - TextReader tr = new StreamReader(logfile); - - while (tr.Peek() != -1) + using (TextReader tr = new StreamReader(logfile)) { - lo.processLine(tr.ReadLine()); + while (tr.Peek() != -1) + { + lo.processLine(tr.ReadLine()); + } } - - tr.Close(); } catch (Exception ex) { diff --git a/Log/LogDownloadscp.cs b/Log/LogDownloadscp.cs index b06810f452..3aaa4e275c 100644 --- a/Log/LogDownloadscp.cs +++ b/Log/LogDownloadscp.cs @@ -517,14 +517,13 @@ private void BUT_redokml_Click(object sender, EventArgs e) LogOutput lo = new LogOutput(); try { - TextReader tr = new StreamReader(logfile); - - while (tr.Peek() != -1) + using (TextReader tr = new StreamReader(logfile)) { - lo.processLine(tr.ReadLine()); + while (tr.Peek() != -1) + { + lo.processLine(tr.ReadLine()); + } } - - tr.Close(); } catch (Exception ex) { diff --git a/Log/LogMap.cs b/Log/LogMap.cs index 0c524d8873..829c82f25f 100644 --- a/Log/LogMap.cs +++ b/Log/LogMap.cs @@ -123,45 +123,41 @@ public static void ProcessFile(string logfile) { // add a bit of buffer var area = RectLatLng.FromLTRB(minx - 0.001, maxy + 0.001, maxx + 0.001, miny - 0.001); - var map = GetMap(area); - - var grap = Graphics.FromImage(map); - - if (sitl) - { - AddTextToMap(grap, "SITL"); - } - - Color[] colours = - { - Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, - Color.Violet, Color.Pink - }; - - int a = 0; - foreach (var locs in loc_list.Values) + using (var map = GetMap(area)) + using (var grap = Graphics.FromImage(map)) { - PointF lastpoint = new PointF(); - var pen = new Pen(colours[a%(colours.Length - 1)]); + if (sitl) + { + AddTextToMap(grap, "SITL"); + } - foreach (var loc in locs) + Color[] colours = { - PointF newpoint = GetPixel(area, loc, map.Size); + Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, + Color.Violet, Color.Pink + }; - if (!lastpoint.IsEmpty) - grap.DrawLine(pen, lastpoint, newpoint); + int a = 0; + foreach (var locs in loc_list.Values) + { + PointF lastpoint = new PointF(); + var pen = new Pen(colours[a % (colours.Length - 1)]); - lastpoint = newpoint; - } + foreach (var loc in locs) + { + PointF newpoint = GetPixel(area, loc, map.Size); - a++; - } + if (!lastpoint.IsEmpty) + grap.DrawLine(pen, lastpoint, newpoint); - map.Save(logfile + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); + lastpoint = newpoint; + } - map.Dispose(); + a++; + } - map = null; + map.Save(logfile + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); + } } else { diff --git a/Log/test/MotorFailure.cs b/Log/test/MotorFailure.cs index 693df16a55..fc6da1b7dc 100644 --- a/Log/test/MotorFailure.cs +++ b/Log/test/MotorFailure.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; +using MissionPlanner.Utilities; namespace MissionPlanner.Log.test { diff --git a/MainV2.cs b/MainV2.cs index 2dd6710337..102a627bfb 100644 --- a/MainV2.cs +++ b/MainV2.cs @@ -1589,6 +1589,21 @@ public void doConnect(MAVLinkInterface comPort, string portname, string baud) MissionPlanner.Utilities.Tracking.AddEvent("Connect", "Baud", comPort.BaseStream.BaudRate.ToString(), ""); + if(comPort.MAV.param.ContainsKey("SPRAY_ENABLE")) + MissionPlanner.Utilities.Tracking.AddEvent("Param", "Value", "SPRAY_ENABLE",comPort.MAV.param["SPRAY_ENABLE"].ToString()); + + if (comPort.MAV.param.ContainsKey("CHUTE_ENABLE")) + MissionPlanner.Utilities.Tracking.AddEvent("Param", "Value", "CHUTE_ENABLE", comPort.MAV.param["CHUTE_ENABLE"].ToString()); + + if (comPort.MAV.param.ContainsKey("TERRAIN_ENABLE")) + MissionPlanner.Utilities.Tracking.AddEvent("Param", "Value", "TERRAIN_ENABLE", comPort.MAV.param["TERRAIN_ENABLE"].ToString()); + + if (comPort.MAV.param.ContainsKey("ADSB_ENABLE")) + MissionPlanner.Utilities.Tracking.AddEvent("Param", "Value", "ADSB_ENABLE", comPort.MAV.param["ADSB_ENABLE"].ToString()); + + if (comPort.MAV.param.ContainsKey("AVD_ENABLE")) + MissionPlanner.Utilities.Tracking.AddEvent("Param", "Value", "AVD_ENABLE", comPort.MAV.param["AVD_ENABLE"].ToString()); + // save the baudrate for this port Settings.Instance[_connectionControl.CMB_serialport.Text + "_BAUD"] = _connectionControl.CMB_baudrate.Text; @@ -1943,10 +1958,10 @@ protected override void OnClosing(CancelEventArgs e) // save config SaveConfig(); - Console.WriteLine(httpthread.IsAlive); - Console.WriteLine(joystickthread.IsAlive); - Console.WriteLine(serialreaderthread.IsAlive); - Console.WriteLine(pluginthread.IsAlive); + Console.WriteLine(httpthread?.IsAlive); + Console.WriteLine(joystickthread?.IsAlive); + Console.WriteLine(serialreaderthread?.IsAlive); + Console.WriteLine(pluginthread?.IsAlive); log.Info("MainV2_FormClosing done"); @@ -2869,6 +2884,30 @@ protected override void OnLoad(EventArgs e) //log.Info("start udpmavlinkshim"); //UDPMavlinkShim.Start(); + BinaryLog.onFlightMode += (firmware, modeno) => + { + try + { + var modes = Common.getModesList((MainV2.Firmwares) Enum.Parse(typeof(MainV2.Firmwares), firmware)); + string currentmode = null; + + foreach (var mode in modes) + { + if (mode.Key == modeno) + { + currentmode = mode.Value; + break; + } + } + + return currentmode; + } + catch + { + return null; + } + }; + GStreamer.onNewImage += (sender, image) => { GCSViews.FlightData.myhud.bgimage = image; }; vlcrender.onNewImage += (sender, image) => diff --git a/Mavlink/MAVLinkInterface.cs b/Mavlink/MAVLinkInterface.cs index bc0e095d47..a6acb870d9 100644 --- a/Mavlink/MAVLinkInterface.cs +++ b/Mavlink/MAVLinkInterface.cs @@ -1762,6 +1762,14 @@ public bool doCommand(byte sysid, byte compid, MAV_CMD actionid, float p1, float giveComport = false; return true; } + else if (actionid == MAV_CMD.PREFLIGHT_CALIBRATION && p6 == 1) + { + // compassmot + // send again just incase + generatePacket((byte)MAVLINK_MSG_ID.COMMAND_LONG, req, sysid, compid); + giveComport = false; + return true; + } else if (actionid == MAV_CMD.PREFLIGHT_CALIBRATION) { retrys = 1; @@ -1778,14 +1786,6 @@ public bool doCommand(byte sysid, byte compid, MAV_CMD actionid, float p1, float // 10 seconds as may need an imu calib timeout = 10000; } - else if (actionid == MAV_CMD.PREFLIGHT_CALIBRATION && p6 == 1) - { - // compassmot - // send again just incase - generatePacket((byte) MAVLINK_MSG_ID.COMMAND_LONG, req, sysid, compid); - giveComport = false; - return true; - } else if (actionid == MAV_CMD.GET_HOME_POSITION) { giveComport = false; @@ -4905,7 +4905,7 @@ public bool translateMode(byte sysid,byte compid, string modein, ref mavlink_set try { - List> modelist = Common.getModesList(MAVlist[sysid,compid].cs); + List> modelist = Common.getModesList(MAVlist[sysid,compid].cs.firmware); foreach (KeyValuePair pair in modelist) { diff --git a/MissionPlanner.csproj b/MissionPlanner.csproj index e0ba13baed..c2e17baa47 100644 --- a/MissionPlanner.csproj +++ b/MissionPlanner.csproj @@ -390,10 +390,6 @@ Control Control Control - - - - Control Control diff --git a/Utilities/Update.cs b/Utilities/Update.cs index 721ad29c14..f876ba6ba8 100644 --- a/Utilities/Update.cs +++ b/Utilities/Update.cs @@ -84,7 +84,8 @@ public static void updateCheckMain(ProgressReporterDialogue frmProgressReporter) process.Start(); log.Info("Quitting existing process"); - frmProgressReporter.BeginInvoke((Action) delegate { Application.Exit(); }); + if (frmProgressReporter != null) + frmProgressReporter.BeginInvoke((Action) delegate { Application.Exit(); }); } catch (AggregateException ex) {