Skip to content

Commit 455a96b

Browse files
committed
Modbus TCP添加端口参数
1 parent e16ddc5 commit 455a96b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

SCADA/Program/ModbusDriver/ModbusTCPDriver.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ public string ServerName
137137
set { _ip = value; }
138138
}
139139

140+
int _port = 502;
141+
public int Port
142+
{
143+
get { return _port; }
144+
set { _port = value; }
145+
}
146+
140147
public bool IsClosed
141148
{
142149
get
@@ -172,7 +179,7 @@ public ModbusTCPReader(IDataServer server, short id, string name)
172179

173180
public bool Connect()
174181
{
175-
int port = 502;
182+
//int port = 502;
176183
try
177184
{
178185
if (tcpSynCl != null)
@@ -185,7 +192,7 @@ public bool Connect()
185192
tcpSynCl.SendTimeout = _timeout;
186193
tcpSynCl.ReceiveTimeout = _timeout;
187194
tcpSynCl.NoDelay = true;
188-
tcpSynCl.Connect(_ip, port);
195+
tcpSynCl.Connect(_ip, _port);
189196
return true;
190197
}
191198
catch (SocketException error)

SCADA/dll/ModbusDriver.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)