BaseSerialPort:
- Flush buffer (DiscardInBuffer) removed as some bytes are missing from time to time. 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. IrdaTransmitProtocol: - WakeUpMessage marked and debug output
This commit is contained in:
@@ -409,6 +409,11 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
/// <remarks date="2019-Dec-14" author="T.Wiedebusch">
|
||||
/// - Flush buffer if received length is 0.
|
||||
/// </remarks>
|
||||
/// <remarks date="2022-Jul-15" author="T.Wiedebusch">
|
||||
/// - Flush buffer (DiscardInBuffer) removed as some bytes are missing from time to time.
|
||||
/// 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>
|
||||
private void ReadingThreadLoop()
|
||||
{
|
||||
//put the receive thread to JoinWaitSleep to avoid reading and logger output for timeout on
|
||||
@@ -464,7 +469,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
rxByte = (Byte)_serialPort.ReadByte();
|
||||
//record raw data stream for output on missing sync-byte to investigate this issue
|
||||
rxRawRecord.Add(rxByte);
|
||||
} while ((_serialPort.BytesToRead > 0) && (PortSettingsForTransmitProtocol.ProtSyncByte != rxByte));
|
||||
} while (_serialPort.BytesToRead > 0 && PortSettingsForTransmitProtocol.ProtSyncByte != rxByte);
|
||||
|
||||
// if syncByte has not been detected skip read loop and wait for next incoming record
|
||||
if (PortSettingsForTransmitProtocol.ProtSyncByte == rxByte)
|
||||
@@ -545,10 +550,10 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
catch (TimeoutException)
|
||||
{
|
||||
//flush receive buffer at timeout to force task to enter JoinWaitSleep state in finally
|
||||
if (_serialPort.IsOpen)
|
||||
{
|
||||
_serialPort.DiscardInBuffer();
|
||||
}
|
||||
//if (_serialPort.IsOpen)
|
||||
//{
|
||||
// _serialPort.DiscardInBuffer();
|
||||
//}
|
||||
|
||||
_byteDataLogger.Trace($"{Ident} Read timeout({InterByteReadDelayMs}ms)");
|
||||
//_byteDataLogger.Trace($"{Ident} Read timeout({PortSettingsForTransmitProtocol.ResponseTimeoutMs}ms)");
|
||||
@@ -655,6 +660,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
||||
|
||||
_serialPort.Write(txByteList.ToArray(), 0, txByteList.Count);
|
||||
|
||||
//TODO THW flush before sending NOT after
|
||||
// flush the buffer for MOXA, to avoid two subsequent communications assembled to one communication!
|
||||
_serialPort.BaseStream.Flush();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user