seanpeery / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

Network Failure #70

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi! I need to reconnect some modbus devices after network failure.
To do this, i tried to follow the steps below: 
1. Check ping to devices (they are PLCs)
2. Create a new instance of a TcpClient object
3. Create a new ModbusIpMaster object using the ModbusIpMaster.CreateIp(client) 
method
4. Add that object to a List of ModbusIpMaster

at the first connection, if Pings are successful, have no problem to write/read 
on shared memory area.

After a network failure (the network cable is unplugged), i restored the 
connection and i tried to clear the list of ModbusIpMaster and follow the steps 
from 1 to 4, but now if i try to read/write i get an InvalidOperationException.

How can i re-initialize the connection to modbus devices, and restart 
reading/writing on modbus?

Thanks

Original issue reported on code.google.com by camnaghi...@gmail.com on 23 Apr 2014 at 2:13

GoogleCodeExporter commented 8 years ago
I resolved the issue.

At ping failure i follow the steps below:
1. Close all TCP connections to Modbus Devices.
2. Dispose all ModbusIpMaster objects

At next ping success you can reconnect following the steps in previous post :)

Original comment by camnaghi...@gmail.com on 30 Apr 2014 at 8:22