slave id check should be disabled in TCP connection

Bug #591142 reported by aladdinwu on 2010-06-08
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Committed
Stéphane Raimbault

Bug Description

According to Page6 in the document "MODBUS Messaging on TCP/IP Implementation Guide V1.0b",

Unit Identifier – This field is used for intra-system routing purpose. It is typically used to communicate to a MODBUS+ or a MODBUS serial line slave through a gateway between an Ethernet TCP-IP network and a MODBUS serial line. This field is set by the MODBUS Client in the request and must be returned with the same value in the response by the server.

So when it's a TCP connection, the slave id check should be disabled in the function modbus_slave_manage. The current code doesn't take the connection type into account:

        if (slave != mb_param->slave && slave != MODBUS_BROADCAST_ADDRESS) {
                // Ignores the query (not for me)
                if (mb_param->debug) {
                        printf("Request for slave %d ignored (not %d)\n",
                               slave, mb_param->slave);

Stéphane Raimbault (sra) wrote :

You're right the slave must be set to 0xFF (I'm sure to have already seen this problem years ago...)
The page 23 better explains how to define unit identifier field in TCP Modbus header (the proxy to serial device must be handled).
I've committed the change and I'm currently modifying the API to still coherent.

Changed in libmodbus:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Stéphane Raimbault (sra)
Stéphane Raimbault (sra) wrote :

The fix was wrong years ago: #181887

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers