Skip to content

Custom table handlers#148

Open
forslund wants to merge 1 commit intostephane:masterfrom
forslund:custom-table-handlers
Open

Custom table handlers#148
forslund wants to merge 1 commit intostephane:masterfrom
forslund:custom-table-handlers

Conversation

@forslund
Copy link
Contributor

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 =)

@forslund
Copy link
Contributor Author

Updated with Julien Blanc's ideas and improved error handling

Main Author Julien Blanc
This patch is a first try at implementing a mechanism to provide
storage backends in replacement of the default one.

This is done through the modbus_storage_backend_vfptable which defines
all functions that needs to be implemented by the callbacks.

The structure passed to modbus_reply is otherwise opaque and passed back
to the callbacks.

The default backend has been updated to be compatible with these changes.

Note : this patch breaks the ABI but tries to keep source compatibility

Error handling moved to the custom request handler as suggested by Daniel
Kirkham.
@forslund
Copy link
Contributor Author

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.

@stephane
Copy link
Owner

Related to #323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants