Hi, I'm writing a code which connect to Modbus. However, when I connect it and try to read coils it will show the error below:-
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond IPAddress
Below is the code that i try to connect and read coils:-
for (startAddress = 0; startAddress < 7; startAddress++)
MBmaster = new Master(IPAddress, 502);
MBmaster.ReadCoils(ID, startAddress, Length);
Any idea how to solve this problem?
Move the MBmaster = new Master(...) out of the for loop, the device can probably only accept one connection from one host.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)