Add clear buffer for serialPort
This commit is contained in:
parent
bc130ea99c
commit
105a4e59f5
|
|
@ -36,7 +36,23 @@ public class SerialPortChannel : ConnectionChannel<SerialPort>
|
||||||
return serialPort;
|
return 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 SerialPort Open() => _Open();
|
||||||
|
|
||||||
protected override void Close(SerialPort serialPort) => serialPort.Dispose();
|
protected override void Close(SerialPort serialPort) => serialPort.Dispose();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue