Browse Source

Modbus TCP添加端口参数

pull/16/head
CookieTang 8 years ago
parent
commit
455a96b91e
  1. 11
      SCADA/Program/ModbusDriver/ModbusTCPDriver.cs
  2. BIN
      SCADA/dll/ModbusDriver.dll

11
SCADA/Program/ModbusDriver/ModbusTCPDriver.cs

@ -137,6 +137,13 @@ namespace ModbusDriver
set { _ip = value; } set { _ip = value; }
} }
int _port = 502;
public int Port
{
get { return _port; }
set { _port = value; }
}
public bool IsClosed public bool IsClosed
{ {
get get
@ -172,7 +179,7 @@ namespace ModbusDriver
public bool Connect() public bool Connect()
{ {
int port = 502; //int port = 502;
try try
{ {
if (tcpSynCl != null) if (tcpSynCl != null)
@ -185,7 +192,7 @@ namespace ModbusDriver
tcpSynCl.SendTimeout = _timeout; tcpSynCl.SendTimeout = _timeout;
tcpSynCl.ReceiveTimeout = _timeout; tcpSynCl.ReceiveTimeout = _timeout;
tcpSynCl.NoDelay = true; tcpSynCl.NoDelay = true;
tcpSynCl.Connect(_ip, port); tcpSynCl.Connect(_ip, _port);
return true; return true;
} }
catch (SocketException error) catch (SocketException error)

BIN
SCADA/dll/ModbusDriver.dll

Binary file not shown.
Loading…
Cancel
Save