stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.44k stars 1.75k forks source link

How to write into signle holding register #625

Closed Adambrin closed 2 years ago

Adambrin commented 2 years ago

Hello, i installed the library, i tested coils, bits succesfully but i dont know how to test write siggle holding register. Say i want to write the value 260 to holding register address 32. Can you please show i can put these to examole unit test client?

mhei commented 2 years ago

This depends on what your device supports: modbus_write_register(3) or modbus_write_registers(3)

Adambrin commented 2 years ago

As a matyer of fact i want to test both of them (single holding register and many holding registers)

Adambrin commented 2 years ago

Here's the output when i try to write single register:

Opening /dev/ttyS2 at 38400 bauds (N, 8, 1)

UNIT TESTING

1/1 No response timeout modification on connect: OK

[01][06][00][21][01][4D][18][65]

Waiting for a confirmation... ERROR Connection timed out: select Bytes flushed (0) 1/2 modbus_write_register:  Line 212: assertion error for 'rc == 1':

Can you advice?

Adambrin commented 2 years ago

Problem solved. Thanks

mhei commented 2 years ago

Then you should close this issue.