FluentModbus icon indicating copy to clipboard operation
FluentModbus copied to clipboard

Added broadcast support to ModbusTcpClient

Open mile-bkoos opened this issue 2 years ago • 4 comments

The ModbusTcpClient missed the support for broadcast messages. I copied the two code parts from the ModbusRtuClient into the ModbusTcpClient.

mile-bkoos avatar Dec 20 '23 10:12 mile-bkoos

Hi, thanks for your contribution! I am quite slow right now, I know. I don't know yet when I will be able to review your changes and I need to be careful with such kind of changes as this project became more popular recently (which means I need to check the specification against your changes).

I will do it eventually but please bear with me :-)

Apollo3zehn avatar Feb 01 '24 16:02 Apollo3zehn

I wanted to merge your changes but it causes many tests to fail.

In the spec (https://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf, p.23) I read about the broadcast support and unit identifiers and found this:

grafik

My understanding is that when talking to Modbus RTU devices, a unit identifier of 0 means broadcast. And when talking to Modbus TCP devices, a unit identifier of 0 is a normal address.

Since the Modbus TCP client cannot distinguish between a regular Modbus TCP server and a Modbus TCP/RTU bridge I am not sure how to implement this properly.

The unit tests fail because they use unit identifier 0 to talk to the server and the newly introduced broadcast checks cause exceptions like Invalid use of broadcast: Unit identifier '0' can only be used for write operations..

Do you have an idea how to implement this properly?

Apollo3zehn avatar Feb 20 '24 12:02 Apollo3zehn

First of all sorry for not running the unit tests before creating the pull requests. In fact we are using it to connect to a modbus RTU gateway / bridge. I added a new flag RTUGatewayMode so that the special handling for the unit identifier 0 only triggers if the flag is set to true :)

mile-bkoos avatar Feb 26 '24 16:02 mile-bkoos

Guys how is this going now? Is it getting merged?

endrelovas avatar Mar 05 '24 06:03 endrelovas