Skip to content

Feature request: single callback with all the values #92

Open

Description

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

Activity

  1. OrangeTux commented on Jul 14, 2020

    @OrangeTux
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions