Skip to content

Commit dc91bcd

Browse files
committed
set default of timeout
1 parent 246bddb commit dc91bcd

File tree

5 files changed

+5
-3
lines changed

5 files changed

+5
-3
lines changed

SCADA/Program/ModbusDriver/ModbusRTUDriver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public bool IsClosed
4747
}
4848
}
4949

50-
private int _timeOut;
50+
private int _timeOut = 1000;
5151
public int TimeOut
5252
{
5353
get { return _timeOut; }
@@ -79,6 +79,7 @@ public bool Connect()
7979
{
8080
if (_serialPort == null)
8181
_serialPort = new SerialPort(_port);
82+
if (_timeOut <= 0) _timeOut = 1000;
8283
_serialPort.ReadTimeout = _timeOut;
8384
_serialPort.WriteTimeout = _timeOut;
8485
_serialPort.BaudRate = _baudRate;

SCADA/Program/ModbusDriver/ModbusTCPDriver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public string GetAddress(DeviceAddress address)
107107
}
108108

109109
#endregion
110-
private int _timeout;
110+
private int _timeout = 1000;
111111

112112
private Socket tcpSynCl;
113113
private byte[] tcpSynClBuffer = new byte[0xFF];
@@ -180,6 +180,7 @@ public bool Connect()
180180
//IPAddress ip = IPAddress.Parse(_ip);
181181
// ----------------------------------------------------------------
182182
// Connect synchronous client
183+
if (_timeout <= 0) _timeout = 1000;
183184
tcpSynCl = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
184185
tcpSynCl.SendTimeout = _timeout;
185186
tcpSynCl.ReceiveTimeout = _timeout;

SCADA/Program/SiemensPLCDriver/SiemensPLCDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public int PDU
4545
}
4646
}
4747

48-
int _timeOut;
48+
int _timeOut = 1000;
4949
public int TimeOut
5050
{
5151
get

SCADA/dll/ModbusDriver.dll

512 Bytes
Binary file not shown.

SCADA/dll/SiemensPLCDriver.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)