Modbus Function Code 6

I am writing code for an Arduino Mega2560R3 which will work within a Modbus server appliance. The code gathers data from another microcontroller and will communicate this data over Modbus to one connected client. There will be only one client connected.

The client will need to change the server’s data register by register. I have no problem writing code to communicate all the server’s registers to the client, however, after studying the Modbus library can’t seems to find a way to change the server’s data register by register.

I assume that function code 6 would be use for this exchange, The called procedure would need to return the register’s address and the data to store there. Is there a function call that implements a single register change? I use the utility ModbusPoll as the client.
I appreciate the group’s help with this. THANKS

if you read with function code 3, you write with function code 6. one register at time.

my ModbusTCP writing function
https://github.com/JAndrassy/Regulator/blob/Regulator/Modbus.ino#L261

Juraj:

Thanks so much for your kind and quick reply. I’ll consider your code.

All the best