1936-modbusSlave-1> g++ -c main.cpp         
1936-modbusSlave-1> g++ -o a.out main.o -ldl
1936-modbusSlave-1> ./a.out                 
krym52.ru

Пример modbus slave. Чуток упростил пример из
https://cpp.hotexamples.com/examples/-/-/modbus_tcp_listen/cpp-modbus_tcp_listen-function-examples.html
0 hold.reg.
listen
accept
The client connection from 127.0.0.1 is accepted
receive
Waiting for an indication...
<00><01><00><00><00><06><FF><03><00><00><00><04>
00 01 00 00 00 06 ff 03 00 00 00 04 
reply
[00][01][00][00][00][0B][FF][03][08][F8][54][40][2D][0F][D0][40][49]
receive
Waiting for an indication...
<00><02><00><00><00><06><FF><03><00><00><00><04>
00 02 00 00 00 06 ff 03 00 00 00 04 
reply
[00][02][00][00][00][0B][FF][03][08][F8][54][40][2D][0F][D0][40][49]
receive
Waiting for an indication...
<00><03><00><00><00><06><FF><03><00><00><00><04>
00 03 00 00 00 06 ff 03 00 00 00 04 
reply
[00][03][00][00][00][0B][FF][03][08][F8][54][40][2D][0F][D0][40][49]
receive
Waiting for an indication...
<00><04><00><00><00><06><FF><03><00><00><00><04>
00 04 00 00 00 06 ff 03 00 00 00 04 
reply
[00][04][00][00][00][0B][FF][03][08][F8][54][40][2D][0F][D0][40][49]
receive
Waiting for an indication...
<00><05><00><00><00><06><FF><03><00><00><00><04>
00 05 00 00 00 06 ff 03 00 00 00 04 
reply
[00][05][00][00][00][0B][FF][03][08][F8][54][40][2D][0F][D0][40][49]
receive
Waiting for an indication...
ERROR Connection reset by peer: read
modbus_receive() returned -1
receive
Waiting for an indication...
ERROR Connection reset by peer: read
modbus_receive() returned -1
receive
Waiting for an indication...
ERROR Connection reset by peer: read
modbus_receive() returned -1
1936-modbusSlave-1> 




build-debug> ./a.out test.txt
krym52.ru

Example modbus TCP master to read 2 REAL value.
Testing application for MV210-101 of OBEH with channels 1 and 3
Library libmodbus.so is used
Call with the only param. config file

connect: iRes=0 errno=115 Operation now in progress
read_registers: iRes=4 errno=115 Operation now in progress
2.71828 3.14159
F854 402D 0FD0 4049 
read_registers: iRes=4 errno=115 Operation now in progress
2.71828 3.14159
F854 402D 0FD0 4049 
read_registers: iRes=4 errno=115 Operation now in progress
2.71828 3.14159
F854 402D 0FD0 4049 
read_registers: iRes=4 errno=115 Operation now in progress
2.71828 3.14159
F854 402D 0FD0 4049 
read_registers: iRes=4 errno=115 Operation now in progress
2.71828 3.14159
F854 402D 0FD0 4049 
build-debug> 


