Skip to content

Commit ef2c457

Browse files
committed
fix length check of "discrete inputs" in DataBank
1 parent 8cf25cd commit ef2c457

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for pyModbusTCP
22

33
0.2.x xxxx-xx-xx
4+
5+
- fix ModbusServer: wrong check of discrete inputs length in DataBank (thanks to OTnetproj).
46
- updated compatibility test (python versions): remove 3.7, add 3.12.
57

68
0.2.1 2023-11-21

pyModbusTCP/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def get_discrete_inputs(self, address, number=1, srv_info=None):
171171
"""
172172
# secure extract of data from list used by server thread
173173
with self._d_inputs_lock:
174-
if (address >= 0) and (address + number <= len(self._coils)):
174+
if (address >= 0) and (address + number <= len(self._d_inputs)):
175175
return self._d_inputs[address: number + address]
176176
else:
177177
return None
@@ -191,7 +191,7 @@ def set_discrete_inputs(self, address, bit_list):
191191
bit_list = [bool(b) for b in bit_list]
192192
# ensure atomic update of internal data
193193
with self._d_inputs_lock:
194-
if (address >= 0) and (address + len(bit_list) <= len(self._coils)):
194+
if (address >= 0) and (address + len(bit_list) <= len(self._d_inputs)):
195195
for offset, b_value in enumerate(bit_list):
196196
self._d_inputs[address + offset] = b_value
197197
else:

0 commit comments

Comments
 (0)