Occasional select() errors with multiple slaves on RS485 bus

16 views
Skip to first unread message

Matteo Iervasi

unread,
Feb 24, 2022, 8:05:57 AM2/24/22
to libmodbus
Hi!

I have been using libmodbus successfully for quite some time now, but I recently faced a problem that I never experienced before.

The problematic setup is built on an RS485 bus with multiple slaves and the master periodically polls data from all the slaves. The address of these slaves are known and fixed. As those slaves can be disconnected and reconnected, the system does a periodic check for those slave addresses and mark the correspondent slave online/offline, and the loop runs for an arbitrary amount of time.

The problem is that there are frequent errors with the communication and if I turn on the libmodbus debug function, I can see that there's this error:
ERROR Operation timed out: select
And then the RTU frame seems to be received in two halves, causing problems with false slaves detection and consequent errors.
I'm attaching a full log here: https://pastebin.com/ZSZTKrkm

I tried debugging the library by embedding its source directly inside my project and I can see that indeed the call to the select() syscall doesn't seem to respect the timeout.
I'm actually not sure if this is something related to libmodbus or the OS, but I ask here anyway given that there are more experienced people.

Thanks in advance
Best regards
Matteo Iervasi
Reply all
Reply to author
Forward
0 new messages