Update protocol parsing logic and warn on invalid protocol

This commit is contained in:
Simon Stürz 2022-06-03 09:28:18 +02:00
parent 70dc99a33f
commit e1d3593dbc

View File

@ -533,19 +533,11 @@ if 'blocks' in registerJson:
validateBlocks(registerJson['blocks']) validateBlocks(registerJson['blocks'])
# Create classes depending on the protocol # Create classes depending on the protocol
writeTcp = True writeTcp = protocol in ["TCP", "BOTH"]
writeRtu = False writeRtu = protocol in ["RTU", "BOTH"]
if not writeTcp and not writeRtu:
if protocol == 'TCP': logger.warning('Invalid protocol definition. Please use TCP, RTU or BOTH.')
writeTcp = True exit(1)
writeRtu = False
elif protocol == 'RTU':
writeTcp = False
writeRtu = True
else:
# Any other value generates both classes
writeTcp = True
writeRtu = True
headerFiles = [] headerFiles = []
sourceFiles = [] sourceFiles = []