I'm trying to connect to a Modbus device (KWH energy meter) over TCP using a Waveshare RS485 to Eth(b) gateway. I'm successfully binding a connection, then sending a packet, but then there is no response and the thrown error says:
Watchdog time expired [ 5 sec]!!! Connection to 192.168.1.254 is not established. in localhost\modbus\Phpmodbus\ModbusMaster.php:167
I can't figure out how to get these communicating correctly or how to find where the issue is? Presumably if the socket is binding then the Client, Destination and port settings are all correct.
Code is:
// Create Modbus object
$modbus = new ModbusMasterUdp("192.168.1.254", "TCP");
try {
// Read input discretes - FC 4
// FC 4 Reads Function Code Registers starts at 30000
$recData = $modbus->readMultipleInputRegisters(1, 1, 2);
//$recData = $modbus->readMultipleRegisters(1, 30000, 2);
FYI: I'm trying to read 30001 and still unsure if I should be useing 1 or 30000 but that will be obvious once comms are established.
Can anyone point me in the right direction please or recommend another library?