Modbus TCP: changing "Unit identifier" dynamically with same IP address

Normally ModbusTCP will use IP address and a “unit identifier” per device:

I have an odd case that need to change the “unit identifier” dynamically with same IP address.
How can it realize in B&R PLC? Library AsMbTcp is using pStation as parameter, it means we still need defined a static “unit identifier” in hardware configuration.

Each function block in AsMbTcp will open/close connection after the pooling or it keep connect to the slave station? Document does not mentions this situation. My slave device only support one concurrent connection.

Hi,

as I know there’s no special function block for changing the modbus device parameters while runtime, and since the “unit identifier” is part of this configuration, you can’t change it “on the fly”.

Changing a hardware configuration in general is possible using mappIO or the functions of the AsIoMMan library, but this always needs a reboot of the PLC to activate the new hardware configuration modules.

Maybe you could try a different, library based ModbusTCP master implementation instead of the built-in driver, which can be found here on Github - I haven’t used it yet, but from the description it looks like that it could meet your needs?

Best regards!

We solved it with this library. This should work.
Best regards Waldemar
MBTCP.zip (192.1 KB)

Thanks @alexander.hefner and @waldemar.salzsehler point out there is solution out there.

After quick read for both libraries, it is same idea that what I want to implement: using AsTCP to reinvent modbus tcp driver. I never test the libraries yet but the solutions definitely will help me to reduce the development time.