APM Planner - 1.0.84

fix ac log download
This commit is contained in:
Michael Oborne 2011-10-18 06:49:49 +08:00
parent b3ca747a69
commit cd2a6026b6
5 changed files with 116 additions and 89 deletions

View File

@ -168,6 +168,8 @@ namespace ArdupilotMega.GCSViews
comPort.ReadBufferSize = 1024 * 1024; comPort.ReadBufferSize = 1024 * 1024;
comPort.PortName = MainV2.comportname;
comPort.Open(); comPort.Open();
System.Threading.Thread t11 = new System.Threading.Thread(delegate() System.Threading.Thread t11 = new System.Threading.Thread(delegate()

View File

@ -56,7 +56,7 @@ namespace ArdupilotMega
public Log() public Log()
{ {
InitializeComponent(); InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false; // so can update display from another thread Control.CheckForIllegalCrossThreadCalls = false; // so can update display from another thread
} }
@ -75,7 +75,8 @@ namespace ArdupilotMega
comPort.DtrEnable = true; comPort.DtrEnable = true;
//comPort.Open(); //comPort.Open();
} }
catch (Exception) { catch (Exception)
{
MessageBox.Show("Error opening comport"); MessageBox.Show("Error opening comport");
} }
@ -99,7 +100,7 @@ namespace ArdupilotMega
comPort_DataReceived((object)null, (SerialDataReceivedEventArgs)null); comPort_DataReceived((object)null, (SerialDataReceivedEventArgs)null);
} }
} }
catch (Exception ex) { Console.WriteLine("crash in comport reader "+ex.ToString()); } // cant exit unless told to catch (Exception ex) { Console.WriteLine("crash in comport reader " + ex.ToString()); } // cant exit unless told to
} }
Console.WriteLine("Comport thread close"); Console.WriteLine("Comport thread close");
}); });
@ -158,7 +159,8 @@ namespace ArdupilotMega
if (!line.Contains("\n")) if (!line.Contains("\n"))
line = line + "\n"; line = line + "\n";
} }
catch { catch
{
line = comPort.ReadExisting(); line = comPort.ReadExisting();
//byte[] data = readline(comPort); //byte[] data = readline(comPort);
//line = Encoding.ASCII.GetString(data, 0, data.Length); //line = Encoding.ASCII.GetString(data, 0, data.Length);
@ -172,26 +174,26 @@ namespace ArdupilotMega
{ {
case serialstatus.Connecting: case serialstatus.Connecting:
if (line.Contains("reset to FLY") || line.Contains("interactive setup")) if (line.Contains("reset to FLY") || line.Contains("interactive setup") || line.Contains("CLI:"))
{ {
comPort.Write("logs\r"); comPort.Write("logs\r");
} }
if (line.Contains("logs")) if (line.Contains("logs"))
{ {
Regex regex2 = new Regex(@"^([0-9]+)", RegexOptions.IgnoreCase); Regex regex2 = new Regex(@"^([0-9]+)", RegexOptions.IgnoreCase);
if (regex2.IsMatch(line)) if (regex2.IsMatch(line))
{
MatchCollection matchs = regex2.Matches(line);
logcount = int.Parse(matchs[0].Groups[0].Value);
genchkcombo(logcount);
status = serialstatus.Done;
}
}
if (line.Contains("No logs"))
{ {
MatchCollection matchs = regex2.Matches(line);
logcount = int.Parse(matchs[0].Groups[0].Value);
genchkcombo(logcount);
status = serialstatus.Done; status = serialstatus.Done;
} }
}
if (line.Contains("No logs"))
{
status = serialstatus.Done;
}
break; break;
case serialstatus.Closefile: case serialstatus.Closefile:
sw.Close(); sw.Close();
@ -199,19 +201,25 @@ namespace ArdupilotMega
MainV2.cs.firmware = MainV2.Firmwares.ArduPlane; MainV2.cs.firmware = MainV2.Firmwares.ArduPlane;
TXT_seriallog.AppendText("Createing KML for " + logfile);
while (tr.Peek() != -1) while (tr.Peek() != -1)
{ {
processLine(tr.ReadLine()); processLine(tr.ReadLine());
} }
tr.Close();
writeKML(logfile + ".kml"); tr.Close();
try
{
writeKML(logfile + ".kml");
}
catch { } // usualy invalid lat long error
status = serialstatus.Done; status = serialstatus.Done;
break; break;
case serialstatus.Createfile: case serialstatus.Createfile:
receivedbytes = 0; receivedbytes = 0;
Directory.CreateDirectory(Path.GetDirectoryName(Application.ExecutablePath)+ Path.DirectorySeparatorChar +@"logs"); Directory.CreateDirectory(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs");
logfile = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + " " + currentlog + ".log"; logfile = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + " " + currentlog + ".log";
sw = new StreamWriter(logfile); sw = new StreamWriter(logfile);
status = serialstatus.Waiting; status = serialstatus.Waiting;
@ -242,32 +250,32 @@ namespace ArdupilotMega
} }
break; break;
} }
lock (thisLock) lock (thisLock)
{
this.BeginInvoke((System.Threading.ThreadStart)delegate()
{
Console.Write(line);
TXT_seriallog.AppendText(line);
// auto scroll
if (TXT_seriallog.TextLength >= 10000)
{ {
this.BeginInvoke((System.Threading.ThreadStart)delegate() TXT_seriallog.Text = TXT_seriallog.Text.Substring(TXT_seriallog.TextLength / 2);
{
Console.Write(line);
TXT_seriallog.AppendText(line);
// auto scroll
if (TXT_seriallog.TextLength >= 10000)
{
TXT_seriallog.Text = TXT_seriallog.Text.Substring(TXT_seriallog.TextLength / 2);
}
TXT_seriallog.SelectionStart = TXT_seriallog.Text.Length;
TXT_seriallog.ScrollToCaret();
TXT_seriallog.Refresh();
});
} }
TXT_seriallog.SelectionStart = TXT_seriallog.Text.Length;
TXT_seriallog.ScrollToCaret();
TXT_seriallog.Refresh();
});
}
} }
Console.WriteLine("exit while"); Console.WriteLine("exit while");
@ -286,17 +294,20 @@ namespace ArdupilotMega
{ {
try try
{ {
Application.DoEvents();
line = line.Replace(", ", ","); line = line.Replace(", ", ",");
line = line.Replace(": ", ":"); line = line.Replace(": ", ":");
string[] items = line.Split(',',':'); string[] items = line.Split(',', ':');
if (items[0].Contains("CMD")) { if (items[0].Contains("CMD"))
{
if (flightdata.Count == 0) if (flightdata.Count == 0)
{ {
if (int.Parse(items[2]) <= (int)MAVLink.MAV_CMD.LAST) // wps if (int.Parse(items[2]) <= (int)MAVLink.MAV_CMD.LAST) // wps
{ {
PointLatLngAlt temp = new PointLatLngAlt(double.Parse(items[5],new System.Globalization.CultureInfo("en-US")) / 10000000, double.Parse(items[6],new System.Globalization.CultureInfo("en-US")) / 10000000, double.Parse(items[4],new System.Globalization.CultureInfo("en-US")) / 100, items[1].ToString()); PointLatLngAlt temp = new PointLatLngAlt(double.Parse(items[5], new System.Globalization.CultureInfo("en-US")) / 10000000, double.Parse(items[6], new System.Globalization.CultureInfo("en-US")) / 10000000, double.Parse(items[4], new System.Globalization.CultureInfo("en-US")) / 100, items[1].ToString());
cmd.Add(temp); cmd.Add(temp);
} }
} }
@ -305,7 +316,7 @@ namespace ArdupilotMega
{ {
positionindex++; positionindex++;
modelist.Add(""); // i cant be bothered doing this properly modelist.Add(""); // i cant be bothered doing this properly
modelist.Add(""); modelist.Add("");
modelist[positionindex] = (items[1]); modelist[positionindex] = (items[1]);
} }
if (items[0].Contains("GPS") && items[2] == "1" && items[4] != "0" && items[4] != "-1" && lastline != line) // check gps line and fixed status if (items[0].Contains("GPS") && items[2] == "1" && items[4] != "0" && items[4] != "-1" && lastline != line) // check gps line and fixed status
@ -317,9 +328,9 @@ namespace ArdupilotMega
if (items.Length == 11 && items[6] == "0.0000") if (items.Length == 11 && items[6] == "0.0000")
alt = double.Parse(items[7], new System.Globalization.CultureInfo("en-US")); alt = double.Parse(items[7], new System.Globalization.CultureInfo("en-US"));
position[positionindex].Add(new Point3D(double.Parse(items[5],new System.Globalization.CultureInfo("en-US")), double.Parse(items[4],new System.Globalization.CultureInfo("en-US")), alt));
position[positionindex].Add(new Point3D(double.Parse(items[5], new System.Globalization.CultureInfo("en-US")), double.Parse(items[4], new System.Globalization.CultureInfo("en-US")), alt));
oldlastpos = lastpos; oldlastpos = lastpos;
lastpos = (position[positionindex][position[positionindex].Count - 1]); lastpos = (position[positionindex][position[positionindex].Count - 1]);
lastline = line; lastline = line;
@ -355,23 +366,23 @@ namespace ArdupilotMega
{ {
if (lastpos.X != 0 && oldlastpos != lastpos) if (lastpos.X != 0 && oldlastpos != lastpos)
{ {
Data dat = new Data(); Data dat = new Data();
runmodel = new Model(); runmodel = new Model();
runmodel.Location.longitude = lastpos.X; runmodel.Location.longitude = lastpos.X;
runmodel.Location.latitude = lastpos.Y; runmodel.Location.latitude = lastpos.Y;
runmodel.Location.altitude = lastpos.Z; runmodel.Location.altitude = lastpos.Z;
runmodel.Orientation.roll = double.Parse(items[1], new System.Globalization.CultureInfo("en-US")) / -100; runmodel.Orientation.roll = double.Parse(items[1], new System.Globalization.CultureInfo("en-US")) / -100;
runmodel.Orientation.tilt = double.Parse(items[2], new System.Globalization.CultureInfo("en-US")) / -100; runmodel.Orientation.tilt = double.Parse(items[2], new System.Globalization.CultureInfo("en-US")) / -100;
runmodel.Orientation.heading = double.Parse(items[3], new System.Globalization.CultureInfo("en-US")) / 100; runmodel.Orientation.heading = double.Parse(items[3], new System.Globalization.CultureInfo("en-US")) / 100;
dat.model = runmodel; dat.model = runmodel;
dat.ctun = ctunlast; dat.ctun = ctunlast;
dat.ntun = ntunlast; dat.ntun = ntunlast;
flightdata.Add(dat); flightdata.Add(dat);
} }
} }
catch { } catch { }
@ -443,11 +454,11 @@ namespace ArdupilotMega
stylecode = colours[g % (colours.Length - 1)].ToArgb(); stylecode = colours[g % (colours.Length - 1)].ToArgb();
Style style2 = new Style(); Style style2 = new Style();
Color color = Color.FromArgb(0xff, (stylecode >> 16) & 0xff,(stylecode >> 8) & 0xff,(stylecode >> 0) & 0xff); Color color = Color.FromArgb(0xff, (stylecode >> 16) & 0xff, (stylecode >> 8) & 0xff, (stylecode >> 0) & 0xff);
Console.WriteLine("colour " + color.ToArgb().ToString("X") + " "+ color.ToKnownColor().ToString()); Console.WriteLine("colour " + color.ToArgb().ToString("X") + " " + color.ToKnownColor().ToString());
style2.Add(new LineStyle(color, 4)); style2.Add(new LineStyle(color, 4));
pm.AddStyle(style2); pm.AddStyle(style2);
@ -529,22 +540,27 @@ namespace ArdupilotMega
} }
catch { } catch { }
pmplane.Point = new KmlPoint((float)model.Location.longitude, (float)model.Location.latitude, (float)model.Location.altitude); try
pmplane.Point.AltitudeMode = altmode; {
Link link = new Link(); pmplane.Point = new KmlPoint((float)model.Location.longitude, (float)model.Location.latitude, (float)model.Location.altitude);
link.href = "block_plane_0.dae"; pmplane.Point.AltitudeMode = altmode;
model.Link = link; Link link = new Link();
link.href = "block_plane_0.dae";
pmplane.Model = model; model.Link = link;
planes.Add(pmplane); pmplane.Model = model;
planes.Add(pmplane);
}
catch { } // bad lat long value
lastmodel = mod.model; lastmodel = mod.model;
a++; a++;
} }
kml.Document.Add(fldr); kml.Document.Add(fldr);
@ -552,7 +568,7 @@ namespace ArdupilotMega
// create kmz - aka zip file // create kmz - aka zip file
FileStream fs = File.Open(filename.Replace(".log.kml",".kmz"),FileMode.Create); FileStream fs = File.Open(filename.Replace(".log.kml", ".kmz"), FileMode.Create);
ZipOutputStream zipStream = new ZipOutputStream(fs); ZipOutputStream zipStream = new ZipOutputStream(fs);
zipStream.SetLevel(9); //0-9, 9 being the highest level of compression zipStream.SetLevel(9); //0-9, 9 being the highest level of compression
zipStream.UseZip64 = UseZip64.Off; // older zipfile zipStream.UseZip64 = UseZip64.Off; // older zipfile
@ -632,7 +648,7 @@ namespace ArdupilotMega
} }
} }
private void downloadthread(int startlognum,int endlognum) private void downloadthread(int startlognum, int endlognum)
{ {
for (int a = startlognum; a <= endlognum; a++) for (int a = startlognum; a <= endlognum; a++)
{ {
@ -642,8 +658,9 @@ namespace ArdupilotMega
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
comPort.Write(a.ToString() + "\r"); comPort.Write(a.ToString() + "\r");
status = serialstatus.Createfile; status = serialstatus.Createfile;
while (status != serialstatus.Done) { while (status != serialstatus.Done)
{
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
} }
@ -660,7 +677,7 @@ namespace ArdupilotMega
System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(500);
comPort.Write("dump "); comPort.Write("dump ");
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
comPort.Write(a.ToString()+"\r"); comPort.Write(a.ToString() + "\r");
status = serialstatus.Createfile; status = serialstatus.Createfile;
while (status != serialstatus.Done) while (status != serialstatus.Done)
@ -687,6 +704,7 @@ namespace ArdupilotMega
System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(500);
comPort.Write("erase\r"); comPort.Write("erase\r");
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
TXT_seriallog.AppendText("!!Allow 30 seconds for erase\n");
status = serialstatus.Done; status = serialstatus.Done;
} }
@ -699,7 +717,7 @@ namespace ArdupilotMega
openFileDialog1.Multiselect = true; openFileDialog1.Multiselect = true;
try try
{ {
openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs"+ Path.DirectorySeparatorChar ; openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar;
} }
catch { } // incase dir doesnt exist catch { } // incase dir doesnt exist
@ -780,7 +798,7 @@ namespace ArdupilotMega
{ {
foreach (string logfile in openFileDialog1.FileNames) foreach (string logfile in openFileDialog1.FileNames)
{ {
TXT_seriallog.AppendText("\n\nProcessing " + logfile+"\n"); TXT_seriallog.AppendText("\n\nProcessing " + logfile + "\n");
this.Refresh(); this.Refresh();
try try
@ -922,4 +940,4 @@ namespace ArdupilotMega
} }
} }
} }

View File

@ -321,6 +321,13 @@ namespace ArdupilotMega
RichTextBox txtr = (RichTextBox)ctl; RichTextBox txtr = (RichTextBox)ctl;
txtr.BorderStyle = BorderStyle.None; txtr.BorderStyle = BorderStyle.None;
} }
else if (((Type)ctl.GetType()) == typeof(CheckedListBox))
{
ctl.BackColor = Color.FromArgb(0x43, 0x44, 0x45);
ctl.ForeColor = Color.White;
CheckedListBox txtr = (CheckedListBox)ctl;
txtr.BorderStyle = BorderStyle.None;
}
else if (((Type)ctl.GetType()) == typeof(TabPage)) else if (((Type)ctl.GetType()) == typeof(TabPage))
{ {
ctl.BackColor = Color.FromArgb(0x26, 0x27, 0x28); //Color.FromArgb(0x43, 0x44, 0x45); ctl.BackColor = Color.FromArgb(0x26, 0x27, 0x28); //Color.FromArgb(0x43, 0x44, 0x45);
@ -682,7 +689,7 @@ namespace ArdupilotMega
private void CMB_serialport_SelectedIndexChanged(object sender, EventArgs e) private void CMB_serialport_SelectedIndexChanged(object sender, EventArgs e)
{ {
comportname = CMB_serialport.Text; comportname = CMB_serialport.Text;
if (comportname == "UDP") if (comportname == "UDP" || comportname == "TCP")
CMB_baudrate.Enabled = false; CMB_baudrate.Enabled = false;
else else
CMB_baudrate.Enabled = true; CMB_baudrate.Enabled = true;

View File

@ -34,5 +34,5 @@ using System.Resources;
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.83")] [assembly: AssemblyFileVersion("1.0.84")]
[assembly: NeutralResourcesLanguageAttribute("")] [assembly: NeutralResourcesLanguageAttribute("")]

View File

@ -11,7 +11,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>xG04b9X6TXBWirLuQOgI+3TR8H0=</dsig:DigestValue> <dsig:DigestValue>sVd4w+f3LroCsyok5UsAi4Bq9eI=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>