You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To test the robustness of our modbus client we'd like the server to throw some errors on requests.
Attempting to do so via hook "modbus.Slave.handle_request" doesn't work properly, because in the except-clause the function code is expected to be available, but it isn't.
To test the robustness of our modbus client we'd like the server to throw some errors on requests.
Attempting to do so via hook "modbus.Slave.handle_request" doesn't work properly, because in the except-clause the function code is expected to be available, but it isn't.
modbus-tk/modbus_tk/modbus.py
Lines 713 to 718 in c168f71
modbus-tk/modbus_tk/modbus.py
Lines 745 to 749 in c168f71
Fix seems trivial, by reordering the code and fetching the function code before calling said hooks.
Hooking more specifically also works fine:
hooks.install_hook("modbus.Slave.handle_read_input_registers_request", self.on_modbus_slave_handle_request)
hooks.install_hook("modbus.Slave.handle_read_holding_registers_request", self.on_modbus_slave_handle_request)
Does it make sense to request this to be changed? Could open a PR if that's helpful.
The text was updated successfully, but these errors were encountered: