From 7a8a04607dd70354e484aa7121739b5413cb574e Mon Sep 17 00:00:00 2001 From: TunaLobster Date: Fri, 5 Nov 2021 11:23:44 -0500 Subject: [PATCH] Attempt at applying new sorting to board serial numbers --- ExtLibs/Utilities/LogSort.cs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ExtLibs/Utilities/LogSort.cs b/ExtLibs/Utilities/LogSort.cs index 3bcf6e64cb..11c22182d5 100644 --- a/ExtLibs/Utilities/LogSort.cs +++ b/ExtLibs/Utilities/LogSort.cs @@ -93,8 +93,13 @@ public static void SortLogs(string[] logs, string masterdestdir = "") var destdir = masterdestdir + Path.DirectorySeparatorChar + "SITL" + Path.DirectorySeparatorChar + aptype.ToString() + Path.DirectorySeparatorChar - + sysid + Path.DirectorySeparatorChar - + brdsernum + Path.DirectorySeparatorChar; + + sysid + Path.DirectorySeparatorChar; + + // add on board serial number parameter if different than default value 0 + if (brdsernum != 0) + { + destdir += brdsernum + Path.DirectorySeparatorChar; + } if (!Directory.Exists(destdir)) @@ -115,7 +120,7 @@ public static void SortLogs(string[] logs, string masterdestdir = "") { var midpoint = binfile.Length / 8; - binfile.Seek(midpoint, SeekOrigin.Begin); + binfile.Seek(0, SeekOrigin.Begin); MAVLink.MAVLinkMessage packet; @@ -149,6 +154,13 @@ public static void SortLogs(string[] logs, string masterdestdir = "") if (hblist.Count > 10) break; } + else if (packet.msgid == (uint)MAVLink.MAVLINK_MSG_ID.PARAM_VALUE) + { + packetsseen++; + var parampkt = (MAVLink.mavlink_param_value_t)packet.data; + if (System.Text.Encoding.ASCII.GetString(parampkt.param_id) == "BRD_SERIAL_NUM") + brdsernum = (int)parampkt.param_value; + } else if (packet != MAVLink.MAVLinkMessage.Invalid) { packetsseen++; @@ -198,16 +210,20 @@ public static void SortLogs(string[] logs, string masterdestdir = "") binfile.Close(); - string destdir = masterdestdir + Path.DirectorySeparatorChar - + aptype.ToString() + Path.DirectorySeparatorChar - + sysid + Path.DirectorySeparatorChar; + string destdir = masterdestdir + Path.DirectorySeparatorChar; if (issitl) { - destdir = masterdestdir + Path.DirectorySeparatorChar - + "SITL" + Path.DirectorySeparatorChar - + aptype.ToString() + Path.DirectorySeparatorChar - + sysid + Path.DirectorySeparatorChar; + destdir += "SITL" + Path.DirectorySeparatorChar; + } + + destdir += aptype.ToString() + Path.DirectorySeparatorChar + + sysid + Path.DirectorySeparatorChar; + + if (brdsernum != 0) + { + Console.WriteLine("found a BRD_SERIAL_NUM"); + destdir += brdsernum + Path.DirectorySeparatorChar; } if (!Directory.Exists(destdir))