diff --git a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/client.py b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/client.py index beea69b023..6581e3cff2 100644 --- a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/client.py +++ b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/client.py @@ -669,9 +669,10 @@ def read_request(self, request): ) self._data.update(request.parse_values(results)) except (AttributeError, ModbusError) as err: - if "Exception code" in err.message: - raise Exception("{0}: {1}".format(err.message, - helpers.TABLE_EXCEPTION_CODE.get(err.message[-1], "UNDEFINED"))) + if err is ModbusError: + code = err.get_exception_code() + raise Exception(f'{err.args[0]}, {helpers.TABLE_EXCEPTION_CODE.get(code, "UNDEFINED")}') + logger.warning("modbus read_all() failure on request: %s\tError: %s", request, err) def read_all(self):