Add clear buffer for serialPort
This commit is contained in:
parent
bc130ea99c
commit
105a4e59f5
|
|
@ -37,6 +37,22 @@ public class SerialPortChannel : ConnectionChannel<SerialPort>
|
|||
};
|
||||
}
|
||||
|
||||
// 👇 NEW: this is where we actually flush the serial buffers
|
||||
protected override void ClearBuffers(SerialPort serialPort)
|
||||
{
|
||||
try
|
||||
{
|
||||
serialPort.DiscardInBuffer();
|
||||
serialPort.DiscardOutBuffer();
|
||||
Console.WriteLine(" Buffer in and out discarded.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine(" couldn't clear the Buffer .");
|
||||
// ignore if port is closed / disposed
|
||||
}
|
||||
}
|
||||
|
||||
protected override SerialPort Open() => _Open();
|
||||
|
||||
protected override void Close(SerialPort serialPort) => serialPort.Dispose();
|
||||
|
|
|
|||
Loading…
Reference in New Issue