Update protocol parsing logic and warn on invalid protocol

master
Simon Stürz 2022-06-03 09:28:18 +02:00
parent 70dc99a33f
commit e1d3593dbc
1 changed files with 5 additions and 13 deletions

View File

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