ProductionUiCordonel: - serial port dispose
This commit is contained in:
@@ -419,6 +419,9 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
/// The IrDA sniffer showed these on the communication line, but they are incompletely received.
|
||||
/// Assuming the DiscardInBuffer may be delayed, so the incoming data will be scrapped.
|
||||
/// </remarks>
|
||||
/// <remarks date="2025-Mai-12" author="T.Wiedebusch">
|
||||
/// - Dispose procedure changed.
|
||||
/// </remarks>
|
||||
private void ReadingThreadLoop()
|
||||
{
|
||||
//put the receive thread to JoinWaitSleep to avoid reading and logger output for timeout on
|
||||
@@ -608,20 +611,23 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_serialPort.IsOpen)
|
||||
{
|
||||
_serialPort.Close();
|
||||
if (_serialPort.IsOpen)
|
||||
{
|
||||
_byteDataLogger.Info($"{Ident} Port close delay!");
|
||||
Thread.Sleep(50);
|
||||
_serialPort.Close();
|
||||
}
|
||||
_serialPort.Dispose();
|
||||
_byteDataLogger.Info($"{Ident} Port is closed");
|
||||
//if (_serialPort.IsOpen)
|
||||
//{
|
||||
// _serialPort.Close();
|
||||
// if (_serialPort.IsOpen)
|
||||
// {
|
||||
// _byteDataLogger.Info($"{Ident} Port closing delay!");
|
||||
// Thread.Sleep(500);
|
||||
// _serialPort.Close();
|
||||
// }
|
||||
// //_serialPort.Dispose();
|
||||
// //_byteDataLogger.Info($"{Ident} Port is closed");
|
||||
//}
|
||||
_serialPort.DiscardInBuffer();
|
||||
_serialPort.DiscardOutBuffer();
|
||||
_serialPort.Close();
|
||||
|
||||
|
||||
}
|
||||
_byteDataLogger.Info($"{Ident} Port is closed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user