libmodbus icon indicating copy to clipboard operation
libmodbus copied to clipboard

Handling Multiple Slave Addresses with libmodbus on a Single Interface

Open piratkin opened this issue 1 year ago • 0 comments

Hi!

I need to create a virtual network of devices on one physical communication interface (RTU). However, from what I understand, the current implementation of the libmodbus library doesn't support listening and responding to a Modbus client using different slave addresses on the same physical interface. I tried listening to each slave_id in a separate thread, but it seems this doesn't work when the physical interfaces overlap.

libmodbus version

3.1.10

OS and/or distribution

Arch Linux

Environment

x86-64

Description

It would be helpful if it were possible to wait for messages from any or random slave_id address instead of a predetermined one.

Actual behavior if applicable

modbus_set_slave(ctx, SERVER_ID);
modbus_receive(modbus, query);

Expected behavior or suggestion

modbus_set_slave(ctx, ANY_SERVER_ID);
modbus_receive(modbus, query);

or

modbus_receive_any(modbus, query);

or something else

piratkin avatar May 24 '24 13:05 piratkin