Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pymodbus/client/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ def convert_to_registers( # noqa: C901
raise TypeError(f"Value should be list of bool but is {type(value)}.")
value = cast(list[bool], value)
if missing := len(value) % 16:
value = value + [False] * (16 - missing)
value += [False] * (16 - missing)
byte_list = pack_bitstring(value)
elif data_type == cls.DATATYPE.STRING:
if not isinstance(value, str):
Expand Down Expand Up @@ -1015,5 +1015,5 @@ def _get_reversed_registers(cls, regs: list[int], data_type: DATATYPE) -> list[i
for x in range(0, len(regs), data_type_len):
single_value_regs = regs[x : x + data_type_len]
single_value_regs.reverse()
reversed_regs = reversed_regs + single_value_regs
reversed_regs += single_value_regs
return reversed_regs
2 changes: 1 addition & 1 deletion pymodbus/datastore/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def validate(self, func_code, address, count=1):
if func_code in self._bits_func_code:
# Bit count, correct to register count
count = (count + WORD_SIZE - 1) // WORD_SIZE
address = address // 16
address //= 16

real_address = self.fc_offset[func_code] + address
if real_address < 0 or real_address > self.register_count:
Expand Down
6 changes: 3 additions & 3 deletions test/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ def test_client_mixin_convert(
regs = ModbusClientMixin.convert_to_registers(value, datatype, **kwargs)
assert regs == registers
result = ModbusClientMixin.convert_from_registers(registers, datatype, **kwargs)
if datatype == ModbusClientMixin.DATATYPE.BITS:
if missing := len(value) % 16:
value = value + [False] * (16 - missing)
# if datatype == ModbusClientMixin.DATATYPE.BITS:
# if missing := len(value) % 16:
# value += [False] * (16 - missing)
if datatype == ModbusClientMixin.DATATYPE.FLOAT32:
if isinstance(result, list):
result = [round(v, 6) for v in result]
Expand Down
Loading