Custom table handlers
Major contributers to this pull request are
- Julien Blanc
- Daniel Kirkham
- Bodo Meissner
- me
After a couple of iterations I've at something that might work regarding the callback functions discussed in the libmodbus google group.
The purpose of this pull request is to have something to discuss and continue to work on, I don't think this is in a mergable state just yet.
Purpose
To allow the user to have custom handlers for registers and coils. This allows them to make libmodbus read/write into existing settings-structures.
I have designed this to make the user defined handler do as little as possible, basically just fetch a register/bit value. It should be very backwards compatible, if no handlers are specified the library uses default handlers that will work just as previous versions.
The error checks are moved to the handlers allowing user to use structures with gaps in the addressing space for example holding register 1-100 are defined and 982 - 999 are also defined. the default (and previous) implementation does not allow for this but nothing hinders the user to define an handler that verifies the address against a list of valid addresses.
Any comments, insights and/or corrections are welcome =)
Updated with Julien Blanc's ideas and improved error handling
Is there anything I can do to get this pull request pulled? We are quite happy with the functionality but if anything needs to be done I'm happy to fix code style issues and such.
Related to https://github.com/stephane/libmodbus/pull/323