WriteMultipleRegistersRequest in TcpModbus implementing

Hello,
I cannot implement the above instruction (WriteMultipleRegistersRequest) TCPModbus in android java.
It seems that I cannot get correctly the syntax of the instruction.
Can somebody post an example ?
Thank you in advance.
Regards Vangelis
 
I recommend consulting the Modbus specifications for the correct syntax.

Refer to section 3.1.2 in the follow specification for details on the contents of a Modbus/TCP packet (i.e. MBAP Header, Function Code, Data):
https://modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf

Refer to section 6.12 in the following specification for the syntax of Function Code 16 (0x10) Write Multiple Registers:
https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf

Here is an example of a write request for Holding Registers 1 and 2, with values of 1 and 2, respectively, on a Modbus/TCP Server with Unit ID 1:
63 00 00 00 00 0B 01 10 00 00 00 02 04 00 01 00 02

The above packet is decoded as follows:

MBAP Header
Transaction Identifier: 6300 Hex (25344 Dec)
Protocol Identifier: 0000 Hex (0 Dec)
Length: 000B Hex (11 Dec)
Unit Identifier: 01 Hex (1 Dec)

Modbus PDU
Function Code: 10 Hex (16 Dec)
Starting Address: 0000 Hex (0 Dec)*
Quantity of Registers: 0002 Hex (2 Dec)
Byte Count: 04 Hex (4 Dec)
Registers Value: 0001 Hex (1 Dec), 0002 Hex (2 Dec)

*Note that the Starting Address in the packet is one less than the register number. In other words, the packet uses 0-based register numbering instead of 1-based numbering. Additional details on Modbus register numbering can be found in this thread:
https://control.com/forums/threads/modbus-register-numbering.49844/
 
Top