Fixed Clear Line issue

This commit is contained in:
2026-06-10 22:42:31 +01:00
parent ba40821bd5
commit 0ffcc4c4e0
4 changed files with 35 additions and 1 deletions
@@ -21,6 +21,9 @@ public interface ISerialPortService
/// Each line is prefixed with "&gt; " (sent) or "&lt; " (received).</summary>
IReadOnlyList<string> GetLines();
/// <summary>Clears the line buffer.</summary>
void ClearLines();
/// <summary>Fired on the SerialPort receive thread when new lines arrive.</summary>
event Action? DataReceived;
}
@@ -97,6 +97,12 @@ public sealed class SerialPortService : ISerialPortService, IDisposable
return _lines.ToList();
}
public void ClearLines()
{
lock (_lock)
_lines.Clear();
}
private void OnDataReceived(object sender, SerialDataReceivedEventArgs e)
{
SerialPort? port;