From f951b60065ec0e06f4694856cc623d704e43dee7 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 27 Aug 2019 17:18:44 -0400 Subject: [PATCH] 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_inno713.py' PyPAD script that caused an infinite loop. --- ChangeLog | 3 + apis/pypad/scripts/pypad_inno713.py | 93 ++++++++++++++--------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6507d116..26e467a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18984,3 +18984,6 @@ 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_filewrite.py' PyPAD script that caused an infinite loop. +2019-08-26 Fred Gleason + * Fixed a bug in the 'pypad_inno713.py' PyPAD script that caused + an infinite loop. diff --git a/apis/pypad/scripts/pypad_inno713.py b/apis/pypad/scripts/pypad_inno713.py index 5698e876..3f8412cb 100755 --- a/apis/pypad/scripts/pypad_inno713.py +++ b/apis/pypad/scripts/pypad_inno713.py @@ -32,55 +32,52 @@ def eprint(*args,**kwargs): def ProcessPad(update): n=1 - while(True): + section='Rds'+str(n) + while(update.config().has_section(section)): + if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW): + dps='' + if(len(update.config().get(section,'DynamicPsString'))!=0): + dps='DPS='+update.resolvePadFields(update.config().get(section,'DynamicPsString'),pypad.ESCAPE_NONE)+'\r\n' + ps='' + if(len(update.config().get(section,'PsString'))!=0): + ps='PS='+update.resolvePadFields(update.config().get(section,'PsString'),pypad.ESCAPE_NONE)+'\r\n' + text='' + if(len(update.config().get(section,'RadiotextString'))!=0): + text='TEXT='+update.resolvePadFields(update.config().get(section,'RadiotextString'),pypad.ESCAPE_NONE)+'\r\n' + if(update.config().has_option(section,'Device')): + # + # Use serial output + # + tty_dev=update.config().get(section,'Device') + speed=int(update.config().get(section,'Speed')) + parity=serial.PARITY_NONE + if int(update.config().get(section,'Parity'))==1: + parity=serial.PARITY_EVEN + if int(update.config().get(section,'Parity'))==2: + parity=serial.PARITY_ODD + bytesize=int(update.config().get(section,'WordSize')) + dev=serial.Serial(tty_dev,speed,parity=parity,bytesize=bytesize) + if(len(dps)!=0): + dev.write(dps.encode('utf-8')) + if(len(ps)!=0): + dev.write(ps.encode('utf-8')) + if(len(text)!=0): + dev.write(text.encode('utf-8')) + dev.close() + else: + # + # Use UDP output + # + ipaddr=update.config().get(section,'IpAddress') + port=int(update.config().get(section,'UdpPort')) + if(len(dps)!=0): + send_sock.sendto(dps.encode('utf-8'),(ipaddr,port)) + if(len(ps)!=0): + send_sock.sendto(ps.encode('utf-8'),(ipaddr,port)) + if(len(text)!=0): + send_sock.sendto(text.encode('utf-8'),(ipaddr,port)) + n=n+1 section='Rds'+str(n) - try: - if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW): - dps='' - if(len(update.config().get(section,'DynamicPsString'))!=0): - dps='DPS='+update.resolvePadFields(update.config().get(section,'DynamicPsString'),pypad.ESCAPE_NONE)+'\r\n' - ps='' - if(len(update.config().get(section,'PsString'))!=0): - ps='PS='+update.resolvePadFields(update.config().get(section,'PsString'),pypad.ESCAPE_NONE)+'\r\n' - text='' - if(len(update.config().get(section,'RadiotextString'))!=0): - text='TEXT='+update.resolvePadFields(update.config().get(section,'RadiotextString'),pypad.ESCAPE_NONE)+'\r\n' - try: - # - # Use serial output - # - tty_dev=update.config().get(section,'Device') - speed=int(update.config().get(section,'Speed')) - parity=serial.PARITY_NONE - if int(update.config().get(section,'Parity'))==1: - parity=serial.PARITY_EVEN - if int(update.config().get(section,'Parity'))==2: - parity=serial.PARITY_ODD - bytesize=int(update.config().get(section,'WordSize')) - dev=serial.Serial(tty_dev,speed,parity=parity,bytesize=bytesize) - if(len(dps)!=0): - dev.write(dps.encode('utf-8')) - if(len(ps)!=0): - dev.write(ps.encode('utf-8')) - if(len(text)!=0): - dev.write(text.encode('utf-8')) - dev.close() - - except configparser.NoOptionError: - # - # Use UDP output - # - ipaddr=update.config().get(section,'IpAddress') - port=int(update.config().get(section,'UdpPort')) - if(len(dps)!=0): - send_sock.sendto(dps.encode('utf-8'),(ipaddr,port)) - if(len(ps)!=0): - send_sock.sendto(ps.encode('utf-8'),(ipaddr,port)) - if(len(text)!=0): - send_sock.sendto(text.encode('utf-8'),(ipaddr,port)) - n=n+1 - except configparser.NoSectionError: - return # # 'Main' function