diff --git a/.gitignore b/.gitignore index cf27052c2d..a8991d7ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ build /Tools/ArdupilotMegaPlanner/obj /Tools/ArdupilotMegaPlanner/resedit/bin /Tools/ArdupilotMegaPlanner/resedit/obj +/Tools/ArdupilotMegaPlanner/wix/bin +/Tools/ArdupilotMegaPlanner/wix/obj tags *.o .*.swp @@ -24,3 +26,5 @@ tags mav.log mav.log.raw status.txt + +/Tools/ArdupilotMegaPlanner/Msi/upload.bat \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index bd24ec4529..3f859b1805 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -80,7 +80,7 @@ ArdupilotMega_TemporaryKey.pfx - true + false false @@ -297,7 +297,7 @@ ConfigTradHeli.cs - UserControl + Form Configuration.cs @@ -939,6 +939,8 @@ + + @@ -952,6 +954,9 @@ + + Always + Always Designer @@ -1049,7 +1054,8 @@ - rem macos.bat + + diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.sln b/Tools/ArdupilotMegaPlanner/ArdupilotMega.sln index 8c86aa7b2d..54de868e9e 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.sln +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.sln @@ -2,9 +2,14 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C# Express 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArdupilotMega", "ArdupilotMega.csproj", "{A2E22272-95FE-47B6-B050-9AE7E2055BF5}" + ProjectSection(ProjectDependencies) = postProject + {76374F95-C343-4ACC-B86F-7ECFDD668F46} = {76374F95-C343-4ACC-B86F-7ECFDD668F46} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{E64A1A41-A5B0-458E-8284-BB63705354DA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wix", "wix\wix.csproj", "{76374F95-C343-4ACC-B86F-7ECFDD668F46}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +46,18 @@ Global {E64A1A41-A5B0-458E-8284-BB63705354DA}.Release|Win32.ActiveCfg = Release|x86 {E64A1A41-A5B0-458E-8284-BB63705354DA}.Release|x86.ActiveCfg = Release|x86 {E64A1A41-A5B0-458E-8284-BB63705354DA}.Release|x86.Build.0 = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|Any CPU.ActiveCfg = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|Win32.ActiveCfg = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|x86.ActiveCfg = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Debug|x86.Build.0 = Debug|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|Any CPU.ActiveCfg = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|Mixed Platforms.Build.0 = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|Win32.ActiveCfg = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|x86.ActiveCfg = Release|x86 + {76374F95-C343-4ACC-B86F-7ECFDD668F46}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tools/ArdupilotMegaPlanner/Common.cs b/Tools/ArdupilotMegaPlanner/Common.cs index 826ae2117d..03e53b26ba 100644 --- a/Tools/ArdupilotMegaPlanner/Common.cs +++ b/Tools/ArdupilotMegaPlanner/Common.cs @@ -386,7 +386,8 @@ namespace ArdupilotMega CH6_ACRO_KP = 25, CH6_YAW_RATE_KD = 26, CH6_LOITER_KI = 27, - CH6_LOITER_RATE_KI = 28 + CH6_LOITER_RATE_KI = 28, + CH6_STABILIZE_KD = 29 } diff --git a/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs b/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs index ae5d6ef677..2fe153f289 100644 --- a/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs +++ b/Tools/ArdupilotMegaPlanner/CommsSerialPort.cs @@ -40,14 +40,14 @@ namespace ArdupilotMega public new static string[] GetPortNames() { - string[] monoDevs = new string[0]; + List allPorts = new List(); if (Directory.Exists("/dev/")) { if (Directory.Exists("/dev/serial/by-id/")) - monoDevs = Directory.GetFiles("/dev/serial/by-id/", "*"); - monoDevs = Directory.GetFiles("/dev/", "*ACM*"); - monoDevs = Directory.GetFiles("/dev/", "ttyUSB*"); + allPorts.AddRange(Directory.GetFiles("/dev/serial/by-id/", "*")); + allPorts.AddRange(Directory.GetFiles("/dev/", "ttyACM*")); + allPorts.AddRange(Directory.GetFiles("/dev/", "ttyUSB*")); } string[] ports = System.IO.Ports.SerialPort.GetPortNames() @@ -55,12 +55,9 @@ namespace ArdupilotMega .Select(FixBlueToothPortNameBug) .ToArray(); - string[] allPorts = new string[monoDevs.Length + ports.Length]; + allPorts.AddRange(ports); - monoDevs.CopyTo(allPorts, 0); - ports.CopyTo(allPorts, monoDevs.Length); - - return allPorts; + return allPorts.ToArray(); } diff --git a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs index 07546e1ac8..66d1128636 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageView.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.pnlPages = new System.Windows.Forms.Panel(); - this.pnlMenu = new BackStageViewMenuPanel(); + this.pnlMenu = new ArdupilotMega.Controls.BackstageView.BackStageViewMenuPanel(); this.SuspendLayout(); // // pnlPages @@ -37,10 +37,10 @@ this.pnlPages.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlPages.Location = new System.Drawing.Point(147, 0); + this.pnlPages.Location = new System.Drawing.Point(150, 0); this.pnlPages.MinimumSize = new System.Drawing.Size(100, 0); this.pnlPages.Name = "pnlPages"; - this.pnlPages.Size = new System.Drawing.Size(243, 189); + this.pnlPages.Size = new System.Drawing.Size(297, 192); this.pnlPages.TabIndex = 0; // // pnlMenu @@ -49,7 +49,7 @@ | System.Windows.Forms.AnchorStyles.Left))); this.pnlMenu.Location = new System.Drawing.Point(0, 0); this.pnlMenu.Name = "pnlMenu"; - this.pnlMenu.Size = new System.Drawing.Size(150, 170); + this.pnlMenu.Size = new System.Drawing.Size(150, 192); this.pnlMenu.TabIndex = 1; // // BackstageView @@ -60,7 +60,7 @@ this.Controls.Add(this.pnlMenu); this.Controls.Add(this.pnlPages); this.Name = "BackstageView"; - this.Size = new System.Drawing.Size(393, 192); + this.Size = new System.Drawing.Size(448, 192); this.ResumeLayout(false); } diff --git a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageViewButton.cs b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageViewButton.cs index 7f384a5bcd..a68c3c94e7 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageViewButton.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/BackstageView/BackstageViewButton.cs @@ -22,10 +22,18 @@ namespace ArdupilotMega.Controls.BackstageView public BackstageViewButton() { + this.SuspendLayout(); + SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.ResizeRedraw, true); this.BackColor = Color.Transparent; + + this.Width = 100; + this.Height = 30; + + + this.ResumeLayout(false); } /// @@ -58,6 +66,15 @@ namespace ArdupilotMega.Controls.BackstageView this.Parent.Invalidate(rectangleToClient); } + protected override void OnPaintBackground(PaintEventArgs pevent) + { + base.OnPaintBackground(pevent); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + } protected override void OnPaint(PaintEventArgs pevent) { diff --git a/Tools/ArdupilotMegaPlanner/Driver/Arduino MEGA 2560.inf b/Tools/ArdupilotMegaPlanner/Driver/Arduino MEGA 2560.inf new file mode 100644 index 0000000000..7053f3b95f --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Driver/Arduino MEGA 2560.inf @@ -0,0 +1,106 @@ +;************************************************************ +; Windows USB CDC ACM Setup File +; Copyright (c) 2000 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} +Provider=%MFGNAME% +LayoutFile=layout.inf +CatalogFile=%MFGFILENAME%.cat +DriverVer=11/15/2007,5.1.2600.0 + +[Manufacturer] +%MFGNAME%=DeviceList, NTamd64 + +[DestinationDirs] +DefaultDestDir=12 + + +;------------------------------------------------------------------------------ +; Windows 2000/XP/Vista-32bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.nt] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.nt +AddReg=DriverInstall.nt.AddReg + +[DriverCopyFiles.nt] +usbser.sys,,,0x20 + +[DriverInstall.nt.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.nt.Services] +AddService=usbser, 0x00000002, DriverService.nt + +[DriverService.nt] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + +;------------------------------------------------------------------------------ +; Vista-64bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.NTamd64] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.NTamd64 +AddReg=DriverInstall.NTamd64.AddReg + +[DriverCopyFiles.NTamd64] +%DRIVERFILENAME%.sys,,,0x20 + +[DriverInstall.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.NTamd64.Services] +AddService=usbser, 0x00000002, DriverService.NTamd64 + +[DriverService.NTamd64] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + + +;------------------------------------------------------------------------------ +; Vendor and Product ID Definitions +;------------------------------------------------------------------------------ +; When developing your USB device, the VID and PID used in the PC side +; application program and the firmware on the microcontroller must match. +; Modify the below line to use your VID and PID. Use the format as shown below. +; Note: One INF file can be used for multiple devices with different VID and PIDs. +; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. +;------------------------------------------------------------------------------ +[SourceDisksFiles] +[SourceDisksNames] +[DeviceList] +%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0010 + +[DeviceList.NTamd64] +%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0010 + + +;------------------------------------------------------------------------------ +; String Definitions +;------------------------------------------------------------------------------ +;Modify these strings to customize your device +;------------------------------------------------------------------------------ +[Strings] +MFGFILENAME="CDC_vista" +DRIVERFILENAME ="usbser" +MFGNAME="Arduino LLC (www.arduino.cc)" +INSTDISK="Arduino Mega 2560 Driver Installer" +DESCRIPTION="Arduino Mega 2560" +SERVICE="USB RS-232 Emulation Driver" \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs index 853d0d4ca1..a05f045ad8 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs @@ -593,29 +593,11 @@ namespace ArdupilotMega.GCSViews DialogResult dr = ofd.ShowDialog(); if (dr == DialogResult.OK) { - StreamReader sr = new StreamReader(ofd.OpenFile()); - while (!sr.EndOfStream) + Hashtable param2 = loadParamFile(ofd.FileName); + + foreach (string name in param2.Keys) { - string line = sr.ReadLine(); - - if (line.Contains("NOTE:")) - CustomMessageBox.Show(line, "Saved Note"); - - int index = line.IndexOf(','); - - int index2 = line.IndexOf(',', index + 1); - - if (index == -1) - continue; - - if (index2 != -1) - line = line.Replace(',', '.'); - - string name = line.Substring(0, index); - float value = float.Parse(line.Substring(index + 1), new System.Globalization.CultureInfo("en-US")); - - MAVLink.modifyParamForDisplay(true, name, ref value); - + string value = param2[name].ToString(); // set param table as well foreach (DataGridViewRow row in Params.Rows) { @@ -647,7 +629,6 @@ namespace ArdupilotMega.GCSViews } } } - sr.Close(); } } @@ -1125,34 +1106,7 @@ namespace ArdupilotMega.GCSViews DialogResult dr = ofd.ShowDialog(); if (dr == DialogResult.OK) { - StreamReader sr = new StreamReader(ofd.OpenFile()); - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - - if (line.Contains("NOTE:")) - CustomMessageBox.Show(line, "Saved Note"); - - int index = line.IndexOf(','); - - if (index == -1) - continue; - - string name = line.Substring(0, index); - float value = float.Parse(line.Substring(index + 1), new System.Globalization.CultureInfo("en-US")); - - MAVLink.modifyParamForDisplay(true, name, ref value); - - if (name == "SYSID_SW_MREV") - continue; - if (name == "WP_TOTAL") - continue; - if (name == "CMD_TOTAL") - continue; - - param2[name] = value; - } - sr.Close(); + param2 = loadParamFile(ofd.FileName); ParamCompare temp = new ParamCompare(this, param, param2); ThemeManager.ApplyThemeTo(temp); @@ -1160,6 +1114,59 @@ namespace ArdupilotMega.GCSViews } } + Hashtable loadParamFile(string Filename) + { + Hashtable param = new Hashtable(); + + StreamReader sr = new StreamReader(Filename); + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + if (line.Contains("NOTE:")) + CustomMessageBox.Show(line, "Saved Note"); + + if (line.StartsWith("#")) + continue; + + string[] items = line.Split(new char[] {' ', ',', '\t' },StringSplitOptions.RemoveEmptyEntries); + + if (items.Length != 2) + continue; + + string name = items[0]; + float value = float.Parse(items[1], new System.Globalization.CultureInfo("en-US")); + + MAVLink.modifyParamForDisplay(true, name, ref value); + + if (name == "SYSID_SW_MREV") + continue; + if (name == "WP_TOTAL") + continue; + if (name == "CMD_TOTAL") + continue; + if (name == "FENCE_TOTAL") + continue; + if (name == "SYS_NUM_RESETS") + continue; + if (name == "ARSPD_OFFSET") + continue; + if (name == "GND_ABS_PRESS") + continue; + if (name == "GND_TEMP") + continue; + if (name == "CMD_INDEX") + continue; + if (name == "LOG_LASTFILE") + continue; + + param[name] = value; + } + sr.Close(); + + return param; + } + private void CHK_GDIPlus_CheckedChanged(object sender, EventArgs e) { if (startup) diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs index f28305e452..0310e66b2f 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Simulation.cs @@ -49,6 +49,10 @@ namespace ArdupilotMega.GCSViews int simPort = 49000; int recvPort = 49005; + // gps buffer + int gpsbufferindex = 0; + ArdupilotMega.MAVLink.__mavlink_gps_raw_t[] gpsbuffer = new MAVLink.__mavlink_gps_raw_t[2]; + // set defaults int rollgain = 10000; int pitchgain = 10000; @@ -1256,7 +1260,13 @@ namespace ArdupilotMega.GCSViews { lastgpsupdate = DateTime.Now; - comPort.sendPacket(gps); + // save current fix = 3 + gpsbuffer[gpsbufferindex % gpsbuffer.Length] = gps; + + // return buffer index + 5 = (3 + 5) = 8 % 6 = 2 + comPort.sendPacket(gpsbuffer[(gpsbufferindex + (gpsbuffer.Length - 1)) % gpsbuffer.Length]); + + gpsbufferindex++; } #endif } diff --git a/Tools/ArdupilotMegaPlanner/MAVLink.cs b/Tools/ArdupilotMegaPlanner/MAVLink.cs index 8299c9e585..380303e239 100644 --- a/Tools/ArdupilotMegaPlanner/MAVLink.cs +++ b/Tools/ArdupilotMegaPlanner/MAVLink.cs @@ -2031,8 +2031,9 @@ namespace ArdupilotMega } } } - catch (Exception e) { log.Info("MAVLink readpacket read error: " + e.Message); break; } + catch (Exception e) { log.Info("MAVLink readpacket read error: " + e.ToString()); break; } + // check if looks like a mavlink packet and check for exclusions and write to console if (temp[0] != 254 && temp[0] != 'U' || lastbad[0] == 'I' && lastbad[1] == 'M' || lastbad[1] == 'G' || lastbad[1] == 'A') // out of sync "AUTO" "GUIDED" "IMU" { if (temp[0] >= 0x20 && temp[0] <= 127 || temp[0] == '\n' || temp[0] == '\r') @@ -2049,6 +2050,7 @@ namespace ArdupilotMega // reset count on valid packet readcount = 0; + if (temp[0] == 'U' || temp[0] == 254) { length = temp[1] + 6 + 2 - 2; // data + header + checksum - U - length @@ -2058,8 +2060,13 @@ namespace ArdupilotMega { if (sysid != temp[3] || compid != temp[4]) { - log.InfoFormat("Mavlink Bad Packet (not addressed to this MAV) got {0} {1} vs {2} {3}", temp[3], temp[4], sysid, compid); - return new byte[0]; + if (temp[3] == '3' && temp[4] == 'D') + { + // this is a 3dr radio rssi packet + } else { + log.InfoFormat("Mavlink Bad Packet (not addressed to this MAV) got {0} {1} vs {2} {3}", temp[3], temp[4], sysid, compid); + return new byte[0]; + } } } @@ -2111,11 +2118,11 @@ namespace ArdupilotMega if (packetlosttimer.AddSeconds(10) < DateTime.Now) { packetlosttimer = DateTime.Now; - packetslost = (int)(packetslost * 0.8f); - packetsnotlost = (int)(packetsnotlost * 0.8f); + packetslost = (packetslost * 0.8f); + packetsnotlost = (packetsnotlost * 0.8f); } - MainV2.cs.linkqualitygcs = (ushort)((packetsnotlost / (packetsnotlost + packetslost)) * 100); + MainV2.cs.linkqualitygcs = (ushort)((packetsnotlost / (packetsnotlost + packetslost)) * 100.0); if (bpstime.Second != DateTime.Now.Second && !logreadmode) { @@ -2161,7 +2168,7 @@ namespace ArdupilotMega if (temp.Length < 5 || temp[temp.Length - 1] != (crc >> 8) || temp[temp.Length - 2] != (crc & 0xff)) { - int packetno = 0; + int packetno = -1; if (temp.Length > 5) { packetno = temp[5]; diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index ecf883be85..6de12700b3 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -23,6 +23,7 @@ using System.Net.Sockets; using IronPython.Hosting; using log4net; using ArdupilotMega.Controls; +using System.Security.Cryptography; namespace ArdupilotMega { @@ -1694,7 +1695,7 @@ namespace ArdupilotMega if (fi.Length != response.ContentLength || response.Headers[HttpResponseHeader.ETag] != CurrentEtag) { - using (StreamWriter sw = new StreamWriter(path + ".etag")) + using (StreamWriter sw = new StreamWriter(path + ".etag.new")) { sw.WriteLine(response.Headers[HttpResponseHeader.ETag]); sw.Close(); @@ -1795,6 +1796,42 @@ namespace ArdupilotMega } + + + private string GetFileETag(string fileName, DateTime modifyDate) + { + + string FileString; + + System.Text.Encoder StringEncoder; + + byte[] StringBytes; + + MD5CryptoServiceProvider MD5Enc; + + //use file name and modify date as the unique identifier + + FileString = fileName + modifyDate.ToString("d", CultureInfo.InvariantCulture); + + //get string bytes + + StringEncoder = Encoding.UTF8.GetEncoder(); + + StringBytes = new byte[StringEncoder.GetByteCount(FileString.ToCharArray(), 0, FileString.Length, true)]; + + StringEncoder.GetBytes(FileString.ToCharArray(), 0, FileString.Length, StringBytes, 0, true); + + //hash string using MD5 and return the hex-encoded hash + + MD5Enc = new MD5CryptoServiceProvider(); + + byte[] hash = MD5Enc.ComputeHash((Stream)File.OpenRead(fileName)); + + return "\"" + BitConverter.ToString(hash).Replace("-", string.Empty) + "\""; + + } + + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Control | Keys.F)) @@ -1823,6 +1860,13 @@ namespace ArdupilotMega frm.Show(); return true; } + if (keyData == (Keys.Control | Keys.W)) // test + { + Form frm = new GCSViews.ConfigurationView.Configuration(); + ThemeManager.ApplyThemeTo(frm); + frm.Show(); + return true; + } if (keyData == (Keys.Control | Keys.T)) // for override connect { try diff --git a/Tools/ArdupilotMegaPlanner/Msi/.gitignore b/Tools/ArdupilotMegaPlanner/Msi/.gitignore new file mode 100644 index 0000000000..197dac0b48 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Msi/.gitignore @@ -0,0 +1,4 @@ + +*.msi +*.wixpdb +*.wixobj \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Msi/installer.bat b/Tools/ArdupilotMegaPlanner/Msi/installer.bat new file mode 100644 index 0000000000..64a7b4d57c --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Msi/installer.bat @@ -0,0 +1,16 @@ +@echo off + +wix.exe ..\bin\release\ + +del installer.wixobj + +"%wix%\bin\candle" installer.wxs -ext WiXNetFxExtension -ext WixDifxAppExtension -ext WixUIExtension.dll -ext WixUtilExtension + + +"%wix%\bin\light" installer.wixobj "%wix%\bin\difxapp_x86.wixlib" -o APMPlannerx86.msi -ext WiXNetFxExtension -ext WixDifxAppExtension -ext WixUIExtension.dll -ext WixUtilExtension + + +"%wix%\bin\light" installer.wixobj "%wix%\bin\difxapp_x64.wixlib" -o APMPlannerx64.msi -ext WiXNetFxExtension -ext WixDifxAppExtension -ext WixUIExtension.dll -ext WixUtilExtension + + +pause diff --git a/Tools/ArdupilotMegaPlanner/Msi/installer.wxs b/Tools/ArdupilotMegaPlanner/Msi/installer.wxs new file mode 100644 index 0000000000..3b70d39505 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Msi/installer.wxs @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed + + + + + + + + + diff --git a/Tools/ArdupilotMegaPlanner/Msi/originstaller.wxs b/Tools/ArdupilotMegaPlanner/Msi/originstaller.wxs new file mode 100644 index 0000000000..111a7cbfd5 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Msi/originstaller.wxs @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed + + + + + + + + + + + + diff --git a/Tools/ArdupilotMegaPlanner/Msi/wix.exe.config b/Tools/ArdupilotMegaPlanner/Msi/wix.exe.config new file mode 100644 index 0000000000..e59af44de2 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/Msi/wix.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/Tools/ArdupilotMegaPlanner/Msi/wix.pdb b/Tools/ArdupilotMegaPlanner/Msi/wix.pdb new file mode 100644 index 0000000000..6dc9934ea7 Binary files /dev/null and b/Tools/ArdupilotMegaPlanner/Msi/wix.pdb differ diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index f695ace3a6..c21a96831d 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs +++ b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ using System.Resources; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.1.59")] +[assembly: AssemblyFileVersion("1.1.60")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/Properties/app.manifest b/Tools/ArdupilotMegaPlanner/Properties/app.manifest index 177b7df33f..8df6208398 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/app.manifest +++ b/Tools/ArdupilotMegaPlanner/Properties/app.manifest @@ -19,8 +19,8 @@ - + diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs index cd1791859a..19d2f1f201 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.cs @@ -75,7 +75,8 @@ namespace ArdupilotMega uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } - catch { + catch + { comPort.Close(); comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; comPort.Open(); @@ -188,13 +189,14 @@ namespace ArdupilotMega { ArdupilotMega.ICommsSerial comPort = new SerialPort(); - try { - comPort.PortName = MainV2.comPort.BaseStream.PortName; - comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; + try + { + comPort.PortName = MainV2.comPort.BaseStream.PortName; + comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; - comPort.ReadTimeout = 4000; + comPort.ReadTimeout = 4000; - comPort.Open(); + comPort.Open(); } @@ -547,7 +549,7 @@ namespace ArdupilotMega } } - Console.WriteLine("responce " + level + " " + ans.Replace('\0',' ')); + Console.WriteLine("responce " + level + " " + ans.Replace('\0', ' ')); // try again if (ans == "" && level == 0) @@ -571,7 +573,7 @@ namespace ArdupilotMega // check for config responce "OK" Console.WriteLine("Connect btr " + comPort.BytesToRead + " baud " + comPort.BaudRate); string conn = comPort.ReadExisting(); - Console.WriteLine("Connect first responce " + conn.Replace('\0',' ') + " " + conn.Length); + Console.WriteLine("Connect first responce " + conn.Replace('\0', ' ') + " " + conn.Length); if (conn.Contains("OK")) { //return true; diff --git a/Tools/ArdupilotMegaPlanner/Setup/Setup.cs b/Tools/ArdupilotMegaPlanner/Setup/Setup.cs index 1bb21aee79..348c1cd0ce 100644 --- a/Tools/ArdupilotMegaPlanner/Setup/Setup.cs +++ b/Tools/ArdupilotMegaPlanner/Setup/Setup.cs @@ -1719,8 +1719,7 @@ namespace ArdupilotMega.Setup #else MainV2.comPort.doAction(MAVLink.MAV_ACTION.MAV_ACTION_CALIBRATE_ACC); #endif - - BUT_levelac2.Text = "Complete"; + BUT_levelplane.Text = "Complete"; } catch { diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/.gitignore b/Tools/ArdupilotMegaPlanner/bin/Release/.gitignore index 7ddb7730c7..de16b06a7a 100644 --- a/Tools/ArdupilotMegaPlanner/bin/Release/.gitignore +++ b/Tools/ArdupilotMegaPlanner/bin/Release/.gitignore @@ -1,3 +1,4 @@ *.pdb *.etag -*.new \ No newline at end of file +*.new +*.log \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb index 3a1d3667b7..bbb6da8b86 100644 Binary files a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb and b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/Driver/Arduino MEGA 2560.inf b/Tools/ArdupilotMegaPlanner/bin/Release/Driver/Arduino MEGA 2560.inf new file mode 100644 index 0000000000..7053f3b95f --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/bin/Release/Driver/Arduino MEGA 2560.inf @@ -0,0 +1,106 @@ +;************************************************************ +; Windows USB CDC ACM Setup File +; Copyright (c) 2000 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} +Provider=%MFGNAME% +LayoutFile=layout.inf +CatalogFile=%MFGFILENAME%.cat +DriverVer=11/15/2007,5.1.2600.0 + +[Manufacturer] +%MFGNAME%=DeviceList, NTamd64 + +[DestinationDirs] +DefaultDestDir=12 + + +;------------------------------------------------------------------------------ +; Windows 2000/XP/Vista-32bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.nt] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.nt +AddReg=DriverInstall.nt.AddReg + +[DriverCopyFiles.nt] +usbser.sys,,,0x20 + +[DriverInstall.nt.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.nt.Services] +AddService=usbser, 0x00000002, DriverService.nt + +[DriverService.nt] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + +;------------------------------------------------------------------------------ +; Vista-64bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.NTamd64] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.NTamd64 +AddReg=DriverInstall.NTamd64.AddReg + +[DriverCopyFiles.NTamd64] +%DRIVERFILENAME%.sys,,,0x20 + +[DriverInstall.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.NTamd64.Services] +AddService=usbser, 0x00000002, DriverService.NTamd64 + +[DriverService.NTamd64] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + + +;------------------------------------------------------------------------------ +; Vendor and Product ID Definitions +;------------------------------------------------------------------------------ +; When developing your USB device, the VID and PID used in the PC side +; application program and the firmware on the microcontroller must match. +; Modify the below line to use your VID and PID. Use the format as shown below. +; Note: One INF file can be used for multiple devices with different VID and PIDs. +; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. +;------------------------------------------------------------------------------ +[SourceDisksFiles] +[SourceDisksNames] +[DeviceList] +%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0010 + +[DeviceList.NTamd64] +%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0010 + + +;------------------------------------------------------------------------------ +; String Definitions +;------------------------------------------------------------------------------ +;Modify these strings to customize your device +;------------------------------------------------------------------------------ +[Strings] +MFGFILENAME="CDC_vista" +DRIVERFILENAME ="usbser" +MFGNAME="Arduino LLC (www.arduino.cc)" +INSTDISK="Arduino Mega 2560 Driver Installer" +DESCRIPTION="Arduino Mega 2560" +SERVICE="USB RS-232 Emulation Driver" \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/srtm.cs b/Tools/ArdupilotMegaPlanner/srtm.cs index 7583ab71c3..3a860c37ee 100644 --- a/Tools/ArdupilotMegaPlanner/srtm.cs +++ b/Tools/ArdupilotMegaPlanner/srtm.cs @@ -24,6 +24,9 @@ namespace ArdupilotMega public static int getAltitude(double lat, double lng, double zoom) { + if (!Directory.Exists(datadirectory)) + Directory.CreateDirectory(datadirectory); + short alt = 0; lat += 0.00083333333333333; diff --git a/Tools/ArdupilotMegaPlanner/temp.Designer.cs b/Tools/ArdupilotMegaPlanner/temp.Designer.cs index ec582ef476..767443ebc4 100644 --- a/Tools/ArdupilotMegaPlanner/temp.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/temp.Designer.cs @@ -198,7 +198,7 @@ // // BUT_lang_edit // - this.BUT_lang_edit.Location = new System.Drawing.Point(365, 164); + this.BUT_lang_edit.Location = new System.Drawing.Point(323, 164); this.BUT_lang_edit.Name = "BUT_lang_edit"; this.BUT_lang_edit.Size = new System.Drawing.Size(75, 23); this.BUT_lang_edit.TabIndex = 16; @@ -208,7 +208,7 @@ // // BUT_georefimage // - this.BUT_georefimage.Location = new System.Drawing.Point(263, 164); + this.BUT_georefimage.Location = new System.Drawing.Point(221, 164); this.BUT_georefimage.Name = "BUT_georefimage"; this.BUT_georefimage.Size = new System.Drawing.Size(96, 23); this.BUT_georefimage.TabIndex = 0; @@ -217,7 +217,7 @@ // // BUT_follow_me // - this.BUT_follow_me.Location = new System.Drawing.Point(527, 164); + this.BUT_follow_me.Location = new System.Drawing.Point(485, 164); this.BUT_follow_me.Name = "BUT_follow_me"; this.BUT_follow_me.Size = new System.Drawing.Size(75, 23); this.BUT_follow_me.TabIndex = 17; @@ -227,7 +227,7 @@ // // BUT_ant_track // - this.BUT_ant_track.Location = new System.Drawing.Point(446, 164); + this.BUT_ant_track.Location = new System.Drawing.Point(404, 164); this.BUT_ant_track.Name = "BUT_ant_track"; this.BUT_ant_track.Size = new System.Drawing.Size(75, 23); this.BUT_ant_track.TabIndex = 18; @@ -237,7 +237,7 @@ // // BUT_magcalib // - this.BUT_magcalib.Location = new System.Drawing.Point(161, 164); + this.BUT_magcalib.Location = new System.Drawing.Point(119, 164); this.BUT_magcalib.Name = "BUT_magcalib"; this.BUT_magcalib.Size = new System.Drawing.Size(96, 23); this.BUT_magcalib.TabIndex = 19; diff --git a/Tools/ArdupilotMegaPlanner/temp.cs b/Tools/ArdupilotMegaPlanner/temp.cs index fd5c9c8c08..219e468aec 100644 --- a/Tools/ArdupilotMegaPlanner/temp.cs +++ b/Tools/ArdupilotMegaPlanner/temp.cs @@ -15,10 +15,16 @@ using GMap.NET.WindowsForms; using GMap.NET.CacheProviders; using log4net; +using System.Security.Permissions; + namespace ArdupilotMega { public partial class temp : Form { + [DllImport("DIFXApi.dll", CharSet = CharSet.Unicode)] + public static extern Int32 DriverPackagePreinstall(string DriverPackageInfPath, Int32 Flags); + + private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public temp() @@ -891,5 +897,13 @@ namespace ArdupilotMega { MagCalib.ProcessLog(); } + + void driverinstall() + { + int result = DriverPackagePreinstall(@"\Driver\XYZ.inf", 0); + if (result != 0) + MessageBox.Show("Driver installation failed."); + + } } } diff --git a/Tools/ArdupilotMegaPlanner/wix/Program.cs b/Tools/ArdupilotMegaPlanner/wix/Program.cs new file mode 100644 index 0000000000..c08e4452db --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/wix/Program.cs @@ -0,0 +1,235 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Windows.Forms; +using System.Diagnostics; + +namespace wix +{ + class Program + { + static int no = 0; + + static StreamWriter sw; + + static List components = new List(); + + static string mainexeid = ""; + + static void Main(string[] args) + { + if (args.Length == 0) + { + Console.WriteLine("Bad Directory"); + return; + } + + string path = args[0]; + + string file = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar+ "installer.wxs"; + + sw = new StreamWriter(file); + + header(); + + sw.WriteLine(""); + + sw.WriteLine(@" + + + + "); + + //sw.WriteLine(""); + + + dodirectory(path, 0); + + + footer(); + + sw.Close(); + + /* + System.Diagnostics.Process P = new System.Diagnostics.Process(); + P.StartInfo.FileName = "cmd.exe"; + + P.StartInfo.Arguments = " /c \"" + Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "installer.bat\""; + P.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath); + P.Start(); + */ + //Console.ReadLine(); + } + + static void header() + { + string newid = System.Guid.NewGuid().ToString(); + + newid = "{625389D7-EB3C-4d77-A5F6-A285CF99437D}"; + + StreamReader sr = new StreamReader(File.OpenRead("../Properties/AssemblyInfo.cs")); + + string version = "0"; + + while (!sr.EndOfStream) { + string line = sr.ReadLine(); + if (line.Contains("AssemblyFileVersion")) + { + string[] items = line.Split(new char[] { '"' },StringSplitOptions.RemoveEmptyEntries); + version = items[1]; + break; + } + } + sr.Close(); + + string data = @" + + + + + + + + + + + + + + + + + + "; + + sw.WriteLine(data); + } + + static void footer() + { + string data = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + sw.WriteLine(data); + + foreach (string comp in components) + { + sw.WriteLine(@""); + } + +data = @" + + + + + + + + + + + + WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed + + + + + + + + +"; + + sw.WriteLine(data); + } + + static void dodirectory(string path, int level = 1) + { + string[] dirs = Directory.GetDirectories(path); + + if (level != 0) + sw.WriteLine(""); + + string[] files = Directory.GetFiles(path); + + sw.WriteLine(""); + + components.Add("_comp"+no); + + foreach (string filepath in files) + { + if (filepath.EndsWith("config.xml") || filepath.Contains("ArdupilotPlanner.log")) + continue; + no++; + sw.WriteLine(""); + + if (filepath.EndsWith("ArdupilotMegaPlanner.exe")) { + mainexeid = "_" + no; + } + } + + sw.WriteLine(""); + + foreach (string dir in dirs) + { + if (dir.EndsWith("gmapcache") || dir.EndsWith("srtm")) + continue; + dodirectory(dir); + } + + if (level != 0) + sw.WriteLine(""); + } + + static string fixname(string name) + { + name = name.Replace("-", "_"); + name = name.Replace(" ", "_"); + name = name.Replace(" ", "_"); + + return name; + } + } +} diff --git a/Tools/ArdupilotMegaPlanner/wix/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/wix/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..145a4d0830 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/wix/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("wix")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("wix")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("072e1c12-4a62-4be2-bcff-01fd33b14f95")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tools/ArdupilotMegaPlanner/wix/app.config b/Tools/ArdupilotMegaPlanner/wix/app.config new file mode 100644 index 0000000000..e59af44de2 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/wix/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Tools/ArdupilotMegaPlanner/wix/wix.csproj b/Tools/ArdupilotMegaPlanner/wix/wix.csproj new file mode 100644 index 0000000000..e20f105243 --- /dev/null +++ b/Tools/ArdupilotMegaPlanner/wix/wix.csproj @@ -0,0 +1,90 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {76374F95-C343-4ACC-B86F-7ECFDD668F46} + Exe + Properties + wix + wix + v2.0 + + + 512 + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + ..\Msi\ + DEBUG;TRACE + prompt + 4 + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file