This is a little Modbus routine I wrote to connect to one remote node, in my case a Dalsa IPD vision device. It's not designed to connect to several devices, just a one-to-one such as my camera setup, a single servo drive or VFD.
As such, it is really optimized for maximum communication to that single device. The module reads the vector of addresses from the slave constantly, as fast as possible. Writes only take place when a value in the Tx Vector is changed. So the PLC always has the freshest possible data in the fastest possible manner.
On the HMI Side, I collected about a dozen different status bits into two message objects, one for the Ethernet adapter and one for the socket.
Special thanks go out to Ash Neilson, who was a tremendous help on getting the serial variation of this running last year.
If you look at the source and find yourself wondering why there are two Socket 3 Busy bits, check out the conversation here:
I hope you find it useful!
Edit: forgot something, added rollover for the RHR / PHR counters and an error count.