Skip to content

ModbusBaseSlaveContext's method async_setValues doesn't allow to pass a tuple as the parameter for values #2692

@Hxz521

Description

@Hxz521

The static type annotation for the values parameter in the async_setValues method of ModbusBaseSlaveContext is Sequence, which allows passing a tuple. However, when subclass objects use this method with a tuple, it doesn‘t work correctly.
After tracing the execution, I found the root cause: the classes of datablock ModbusSequentialDataBlock and ModbusSparseDataBlock handle non-list inputs by wrapping the entire input into a single-element list , for example (1,2,3) ->[ (1,2,3) ] ,1->[1] .It works when passing a single data to the method . I think we should add logic to handle tuple inputs in classes of datablock or simply change the static annotation from Sequence to `list in order to prevent misunderstanding.
pymodbus version : 3.9.2 ( it is the same on the dev latest branch )

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