Skip to content

Commit abff605

Browse files
fix TCP client example and unittest for incremented value due to on_get callback
1 parent c4a7efa commit abff605

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

examples/tcp_client_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def my_inputs_register_get_cb(reg_type, address, val):
107107

108108
# any operation should be as short as possible to avoid response timeouts
109109
# It would be also possible to read the leatest pin state at this time
110-
val += 1
110+
val[0] += 1
111111
client.set_ist(address=address, value=val)
112112
print('Incremented current value by +1 before sending response')
113113

tests/test_tcp_example.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ def test_read_input_registers_single(self) -> None:
542542
expectation = \
543543
(self._register_definitions['IREGS']['EXAMPLE_IREG']['val'], )
544544

545+
# due to value increment by registered callback in
546+
# tcp_client_example.py, see #31 and #51
547+
expectation[0] += 1
548+
545549
register_value = self._host.read_input_registers(
546550
slave_addr=self._client_addr,
547551
starting_addr=ireg_address,

0 commit comments

Comments
 (0)