-216 is the subroutines timeout error code - it sent the request and did not receive a response within whatever timeout setting you have set in the ntParameters.
Had this system worked before or is this something new you are working on?
Can you communicate with the pressure controller using a utility like Modbus poll?
I don’t know why your register returns 32767 as I don’t think the Modbus subroutines would put that value in there - that could be coming from your pressure controller.
Not being able to reach the PAC Controller is another concern - if you are opening and closing a lot of TCP comm handles in your strategy then that could happen - what else do you have running on this controller? You also could have a network issue of some kind.
pdate:
The Modbus Master chart is now successfully Running in PAC Control! However, n03AsIntStatus is still returning a -216 timeout error.
The communication handle value is configured as: tcp:192.168.1.2:22522.
Since the status is still -216, could this be a Unit ID (Slave Address) parameter mismatch inside the integration kit, or is the controller dropping packets because of the custom port 22522 instead of standard 502? Any advice on what to verify next on the controller side while the client is setting up the hardware reboot?
This is an existing system, and the pressure controller is communicating with the SNAP PAC R1 over Ethernet using Modbus TCP. We are not using a serial module, and the Modbus parameters are configured for TCP, not RTU.
The communication handle is:
tcp:192.168.1.2:22522
The issue is intermittent: sometimes the Modbus read works, but n03AsIntStatus changes between 0 and -216 timeout.
Could the custom TCP port 22522 or any Modbus TCP configuration on the pressure controller be related to this timeout? Please let me know what parameters or diagnostics you recommend checking next.
I increased the Modbus timeout in my strategy from 500ms to 2000ms and added a retry with a small delay. The n03AsIntStatus = -216 timeout is now much less frequent, but it still happens intermittently.
You are right about Wireshark. I will take a Wireshark trace on 192.168.1.2 port 22522 to check if the pressure controller is closing the TCP socket or not responding to the Modbus TCP query. I will also check the pressure controller’s side for Modbus TCP server settings - max connections and response delay for this custom port 22522.
Thanks again for pointing me in the right direction. I will update the thread once I have the trace results.
You may want to add a ClearCommunicationReceiveBuffer(chCommHandle); before you call the modbus subroutine as well in case a response came in after the timeout and is sitting in the buffer before the next request.