Closed jmcphail closed 7 months ago
I think the problem here is that you are using $unitID = 0;
in FC6.php example. I can see that from packet that is sent 6fcd00000006000600100001
Here is FC6 request explained: https://github.com/aldas/modbus-tcp-client/blob/53657b3de8f90c9e6727c9aca841b3e355fbe554/src/Packet/ModbusFunction/WriteSingleRegisterRequest.php#L19-L26
So 6fcd00000006000600100001
is sending packet to Unit/Slave address = 0
but in modpoll you are sending to UnitID = 1. This is that -a 1
argument.
If I recall correctly Unit/Slave 0 is "broadcast" address which may and may not work for some PLCs
Thank you for your efforts and for the second pair of eyes. This has resolved the 'time out'
$connection = BinaryStreamConnection::getBuilder()
->setPort(1502)
->setHost('192.168.1.97')
->setConnectTimeoutSec(1.5) // timeout when establishing connection to the server
->setWriteTimeoutSec(5) // timeout when writing/sending packet to the server
->setReadTimeoutSec(5) // timeout when waiting response from server
->build();
$startAddress = 16;
$value = 1;
$unitID = 1;
$packet = new WriteSingleRegisterRequest($startAddress, $value, $unitID);
I am trying to write a single register value using the FC6 example. Slave device is a RMS200 from EtherTek Circuits. I have modified the example code to match my environment:
This is the output from the FC6 example:
FC3 example working correctly. Modpoll write command working correctly:
Here is tcpdump capture of FC6 example request:
Can you help see where problem is? Is it an unexpected slave device response? Library error? The odd thing is the FC6 command is properly received by device (modbus register value is confirmed as changed). It appears as though the slave response is not recognized by library.