Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: single callback with all the values #92

Open
ghost opened this issue May 22, 2020 · 1 comment
Open

Feature request: single callback with all the values #92

ghost opened this issue May 22, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented May 22, 2020

I see a need for an ability to get a callback with all the values in a multi-read or multi-write request at once. The callback would then return a list (or iterator) of values in the case of a read operation.

In my case I have a situation where typically 2 adjacent modbus registers map to the high/low parts of an internal parameter, and I want to be able to handle writes atomically and send data from the same point in time for reads.

I don't see an obvious way to add this functionality, though, and right now I inject an alternative implementation of WriteMultipleRegisters.execute() that doesn't have the loop but calls the callback immediately instead.

This is related to #73, and would provide a more generally useful interface (IMHO).

@OrangeTux
Copy link
Collaborator

I'm sorry for this late response. I missed this issue.
I think I like the idea of configuring a callback. I need to thing about a nice API, but I can already share my first ideas.

I think one should be able to configure a callback for one or several function codes. The callback is than called with an instance of umodbus.functions.ModbusFunction. I'm not sure yet what the callback should return.

Also what should happen if one has integrated both a callback for a specific function code as well as a 'regular' route? Should both executed? If so, in what order?

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

No branches or pull requests

1 participant