Skip to content

Commit aaba2a8

Browse files
author
lucas.freire
committed
fixed string type handling in simulator
1 parent eb84cfe commit aaba2a8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pymodbus/datastore/simulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ def handle_type_float32(self, start, stop, value, action, action_parameters):
198198

199199
def handle_type_string(self, start, stop, value, action, action_parameters):
200200
"""Handle type string."""
201-
regs = stop - start
201+
regs = stop - start + 1
202202
reg_len = regs * 2
203203
if len(value) > reg_len:
204204
raise RuntimeError(
205205
f'ERROR "{Label.type_string}" {start} too long "{value}"'
206206
)
207207
value = value.ljust(reg_len)
208-
for i in range(stop - start):
208+
for i in range(stop - start + 1):
209209
reg = self.runtime.registers[start + i]
210210
if reg.type != CellType.INVALID:
211211
raise RuntimeError(f'ERROR "{Label.type_string}" {start + i} used')

0 commit comments

Comments
 (0)