Skip to content

Commit

Permalink
MAVLinkInterface: add plaintext buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jun 21, 2024
1 parent 310b448 commit 1b1880c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ public bool giveComport

private DateTime lastparamset = DateTime.MinValue;

/// <summary>
/// stores a list of strings during connect for possible debug
/// </summary>
internal List<string> plaintxtlinebuffer = new List<string>(30);

/// <summary>
/// stores a single string during connect for possible debug
/// </summary>
internal string plaintxtline = "";
private string buildplaintxtline = "";

Expand Down Expand Up @@ -713,21 +721,16 @@ private void OpenBg(IProgressReporterDialogue PRsender, bool getparams)
if (hbseen)
{
PRsender.doWorkArgs.ErrorMessage = Strings.Only1Hb;
throw new Exception(Strings.Only1HbD);
throw new Exception(Strings.Only1HbD + plaintxtlinebuffer.Aggregate((a, b) => a + "\r\n" + b));
}
else
{
PRsender.doWorkArgs.ErrorMessage = "No Heartbeat Packets Received";
throw new TimeoutException(@"Can not establish a connection
Please check the following
1. You have firmware loaded
2. You have the correct serial port selected
3. PX4 - You have the microsd card installed
4. Try a diffrent usb port
No Mavlink Heartbeat Packets where read from this port - Verify Baud Rate and setup
Mission Planner waits for 2 valid heartbeat packets before connecting");
Mission Planner waits for 2 valid heartbeat packets before connecting
" + plaintxtlinebuffer.Aggregate((a, b) => a + "\r\n" + b));
}
}

Expand Down Expand Up @@ -4692,7 +4695,12 @@ public async Task<MAVLinkMessage> readPacketAsync()
{
// check new line is valid
if (buildplaintxtline.Length > 3)
{
plaintxtline = buildplaintxtline;
plaintxtlinebuffer.Insert(0, plaintxtline);
while (plaintxtlinebuffer.Count >= 30)
plaintxtlinebuffer.RemoveAt(plaintxtlinebuffer.Count - 1);
}

log.Info(plaintxtline);
// reset for next line
Expand Down

0 comments on commit 1b1880c

Please sign in to comment.