Skip to content

Commit

Permalink
Attempt at applying new sorting to board serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
TunaLobster authored and meee1 committed Oct 3, 2023
1 parent 3a8e82a commit 7a8a046
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions ExtLibs/Utilities/LogSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;

Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 7a8a046

Please sign in to comment.