I am running the following program successfully...I would however like the ability to break out of it if I am not seeing the results I expect and still retain the variable k so that I can query the test equipment....The KeyboardInterrupt does not seem to work...when I hit a keystroke of any kind I see it entered onto the IDLE shell but program does not break out of loop...Can anyone give me ideas?

Thanks

from BK_Logger import BK_scpi
import time

def main():
    bk = BK_scpi('TadiranTLH5930', 'bk')

    bk.blankScreen()
    m = bk.CreateResource()
    bk.dataLogOpen()
    bk.BKInit()
    while True:
        try:
            (int(m.query('stat:oper?')) == 32)
        except KeyboardInterrupt:
            print('key hit')
            break
        except:
            continue

        if (int(m.query('*opc?')) == 1):
            volts = float('{:4.3f}'.format(float(m.query('fetc:volt?').strip())))
            time.sleep(0.2)

    return m

k = main()
print('...commands use k.write and k.query....')

0 Answers