Skip to content

Commit 5f0e25d

Browse files
call on_set_cb before sending response to requester, relates to #31, found during #51
1 parent 1793bf3 commit 5f0e25d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

umodbus/modbus.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ def _process_read_access(self, request: Request, reg_type: str) -> None:
140140
address = request.register_addr
141141

142142
if address in self._register_dict[reg_type]:
143-
vals = self._create_response(request=request, reg_type=reg_type)
144-
request.send_response(vals)
145143

146144
if self._register_dict[reg_type][address].get('on_get_cb', 0):
145+
vals = self._create_response(request=request,
146+
reg_type=reg_type)
147147
_cb = self._register_dict[reg_type][address]['on_get_cb']
148148
_cb(reg_type=reg_type, address=address, val=vals)
149+
150+
vals = self._create_response(request=request, reg_type=reg_type)
151+
request.send_response(vals)
149152
else:
150153
request.send_exception(Const.ILLEGAL_DATA_ADDRESS)
151154

@@ -382,7 +385,7 @@ def add_ist(self,
382385

383386
def remove_ist(self, address: int) -> Union[None, bool, List[bool]]:
384387
"""
385-
Remove a holding register from the modbus register dictionary.
388+
Remove a discrete input register from the modbus register dictionary.
386389
387390
:param address: The address (ID) of the register
388391
:type address: int

0 commit comments

Comments
 (0)