diff --git a/pymodbus/client/mixin.py b/pymodbus/client/mixin.py index ca5897983..8a9f09727 100644 --- a/pymodbus/client/mixin.py +++ b/pymodbus/client/mixin.py @@ -701,7 +701,7 @@ def convert_from_registers( :param registers: list of registers received from e.g. read_holding_registers() :param data_type: data type to convert to - :param word_order: "big"/"little" order of words/registers + :param word_order: "big"/"little" order of words/registers (Only used for special devices) :returns: scalar or array of "data_type" :raises ModbusException: when size of registers is not a multiple of data_type """ @@ -742,7 +742,7 @@ def convert_to_registers( :param value: value to be converted :param data_type: data type to convert from - :param word_order: "big"/"little" order of words/registers + :param word_order: "big"/"little" order of words/registers (Only used for special devices) :returns: List of registers, can be used directly in e.g. write_registers() :raises TypeError: when there is a mismatch between data_type and value """ @@ -771,3 +771,38 @@ def convert_to_registers( if word_order == "little": regs.reverse() return regs + + @classmethod + def convert_combined_from_registers( + cls, registers: list[int], data_types: list[tuple[DATATYPE, int]], word_order: Literal["big", "little"] = "big" + ) -> list[bool | int | float | str]: + """Convert registers to int/float/str. + + :param registers: list of registers received from e.g. read_holding_registers() + :param data_types: list of (data type, count) to convert to + :param word_order: "big"/"little" order of words/registers (Only used for special devices) + :returns: scalar or array of "data_type" + :raises ModbusException: when size of registers is not a multiple of data_type + """ + _ = registers + _ = data_types + _ = word_order + return [32] + + + @classmethod + def convert_combined_to_registers( + cls, values: list[bool | int | float | str] , data_types: list[DATATYPE], word_order: Literal["big", "little"] = "big" + ) -> list[int]: + """Convert int/float/str to registers (16/32/64 bit). + + :param values: list of values to be converted + :param data_types: list of data types to convert from (Only used for special devices) + :param word_order: "big"/"little" order of words/registers + :returns: List of registers, can be used directly in e.g. write_registers() + :raises TypeError: when there is a mismatch between data_type and value + """ + _ = values + _ = data_types + _ = word_order + return [12]