Libmodbus responding to all slave ids in modbus rtu slave mode

139 views
Skip to first unread message

Savindra Kumar

unread,
Feb 27, 2021, 4:55:29 AM2/27/21
to libm...@googlegroups.com
Hi,

I am using libmodbus version 3.1.6 on linux platform. I have created a modbus rtu slave and slave id is 100. This slave is responding to queries even if i give slave ids other than 100.Ideally it should reject the query.

Attaching debug log. 

 
 
Thanks & Regards
Savindra Kumar.
snap.JPG

Chuck Watson

unread,
Feb 27, 2021, 10:36:26 AM2/27/21
to libm...@googlegroups.com

You need to remember that all slaves hear all traffic on the wire in an RTU situation.

 

It is up to the slave to determine if the message is for that device or another slave on the wire.

 

You need break the message down into its components to get the node/slave address the message is intended for and either ignore or reply.

 

I found this site helpful for breaking down the message. http://www.simplymodbus.ca/FC03.htm

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/CAPGd1xvYyQ9%2BBNAxJ_B3kc7Kf%2BemoxzdkVzuT72koFw%3DOYzPEQ%40mail.gmail.com.

Savindra Kumar

unread,
Feb 27, 2021, 11:55:37 PM2/27/21
to libm...@googlegroups.com
Thanks for your reply. 
So my requirement was to ignore the message if slave id is not matched from the request but i saw libmodbus was always replying to modbus rtu master even if request is not for that slave. 

Is there a way I can disable reply from libmodbus in case request is not for particular slave? I want to notify master that response is timed out and there is not such slave on RS485 bus. 

Thanks

Chuck Watson

unread,
Mar 1, 2021, 12:40:28 PM3/1/21
to libm...@googlegroups.com

Yes, slave should ignore messages not for them.

 

Timeouts: If the master sends a request out and no slave replies after a certain time, that is the definition of timeout and is for the master to detect and act accordingly like put device into slow polling for example.

 

This has nothing to do with any other part of the system. The slaves are not normally aware of other slaves on the network.

Savindra Kumar

unread,
Mar 2, 2021, 12:05:11 AM3/2/21
to libm...@googlegroups.com
Coming to my question which I had asked in starting, libmodbus slave is not ignoring the message. 

I had set slave id 100 using libmodbus api if I am sending slave id other than 100 in query than also libmodbus slave sending reply. 

Chuck Watson

unread,
Mar 2, 2021, 11:26:31 AM3/2/21
to libm...@googlegroups.com

Then there is a slave that is not working correctly.

Saurabh Mishra

unread,
Mar 8, 2021, 2:59:09 AM3/8/21
to libm...@googlegroups.com
Hey Savindra,

This is regarding the Libmodbus query, please share your source code files to look into the issue.


Sincerely,

Saurabh Mishra

Cell- (+91) 9415561370

Skype ID- skmis_1



--
Reply all
Reply to author
Forward
0 new messages