Allow checkReachableRegister to be defined also within a block

master
Simon Stürz 2022-08-05 18:04:26 +02:00
parent 2de980e9a5
commit 5db18ec40f
2 changed files with 13 additions and 1 deletions

View File

@ -127,7 +127,7 @@ Depending on your device the amount of errors in a row can vary and can be speci
In order to check if the device is reachable, a register can be defined by the developer as a test register.
For this purpose the `checkReachableRegister` property has been introduced. The property describes the `id` of the register which will be used for testing the communication. The register should be mandatory on the device
and only one register in size to speed up things. During the check the response data will be ignored, only the communication will be tested. The register must be *readable* and be defined in the `registers` section of your JSON file.
and only one register in size to speed up things. During the check the response data will be ignored, only the communication will be tested. The register must be *readable* and be defined in the `registers` section of your JSON file or in a block.
## Endianness

View File

@ -758,6 +758,18 @@ for registerDefinition in registerJson['registers']:
registerExists = True
break
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
for registerDefinition in blockDefinition['registers']:
if registerDefinition['id'] == checkReachableRegister:
if not 'R' in registerDefinition['access']:
logger.warning('Error: The specified \"checkReachableRegister\" is not readable. Please select a manadtory readable register as checkReachableRegister.')
exit(1)
checkReachableRegister = registerDefinition
registerExists = True
break
if not registerExists:
logger.warning('Error: Could not find the given \"checkReachableRegister\". Please make sure the specified register matches the \"id\" of a defined register.')
exit(1)