Skip to content

Conversation

@rahulraghu94
Copy link
Contributor

Using the Error Response API in place of manually checking for error codes in examples

rahul added 3 commits January 8, 2018 15:31
@rahulraghu94
Copy link
Contributor Author

@dhoomakethu , all tests using the error API

count,
self.unit_id)
return result.function_code < 0x80
return result.isError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be return not result.isError()

rq = self.client.write_coil(1, True)
rr = self.client.read_coils(1,1)
self.__validate(rq, lambda r: r.function_code < 0x80)
self.__validate(rq, lambda r: r.isError())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check should be for not isError()

rq = self.client.write_coils(1, [True]*8)
rr = self.client.read_coils(1,8)
self.__validate(rq, lambda r: r.function_code < 0x80)
self.__validate(rq, lambda r: r.isError())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

rq = self.client.write_coils(1, [False]*8)
rr = self.client.read_discrete_inputs(1,8)
self.__validate(rq, lambda r: r.function_code < 0x80)
self.__validate(rq, lambda r: r.isError())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

rq = self.client.write_register(1, 10)
rr = self.client.read_holding_registers(1,1)
self.__validate(rq, lambda r: r.function_code < 0x80)
self.__validate(rq, lambda r: r.isError())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

_logger.debug("validate[%d] %d:%d" % (fx, address, count))
result = self.__get_callbacks[self.decode(fx)](address, count)
return result.function_code < 0x80
return True if result.isError() is False else False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify return not result.isError()

@rahulraghu94
Copy link
Contributor Author

@dhoomakethu , this is ready now.

@dhoomakethu dhoomakethu force-pushed the #82-error-response-api branch from e4abb1a to bbf6fed Compare April 27, 2018 09:15
@dhoomakethu dhoomakethu merged commit 693783b into dev Apr 27, 2018
@dhoomakethu dhoomakethu deleted the #82-error-response-api branch May 10, 2018 11:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants