Status Reporting
37
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
1345
IO_COMPLETE = 1 << IOC_BIT
# 1 leftshift 13 = 8192
# Test for armed.
STATUS_REGISTER = int(KsInfiniiVisionX.query(":OPER?"))
IO_COMPLETE_STATUS = STATUS_REGISTER & IOC_MASK
# Wait indefinitely until armed.
while IO_COMPLETE_STATUS != IO_COMPLETE:
# Check the status again after small delay.
time.sleep(0.1)
# 100 ms delay to prevent excessive queries.
STATUS_REGISTER = int(KsInfiniiVisionX.query(":OPER?"))
IO_COMPLETE_STATUS = STATUS_REGISTER & IOC_MASK
time_in_seconds = str(time.clock() - now)
print "IO Operation Complete (from :OPER? query)."
print "It took %s seconds for IO operation to complete.\n" % \
time_in_seconds
# ====================================================================
# Main
# ====================================================================
# Connect and initialize oscilloscope
# --------------------------------------------------------------------
# Define VISA Resource Manager & Install directory
rm = visa.ResourceManager('C:\\Windows\\System32\\agvisa32.dll')
# Define and open the oscilloscope using the VISA address
KsInfiniiVisionX = rm.open_resource(VISA_ADDRESS)
# Set the Global Timeout
KsInfiniiVisionX.timeout = GLOBAL_TOUT
# Clear the instrument bus
KsInfiniiVisionX.clear()
# Reset the oscilloscope.
# KsInfiniiVisionX.write("*RST")
# Or comment out to use the current oscilloscope setup.
# Autoscale to set up vertical scale and trigger level on channels 1 and
2.
KsInfiniiVisionX.write(":CHANnel1:DISPlay ON")
KsInfiniiVisionX.write(":CHANnel2:DISPlay ON")
KsInfiniiVisionX.write(":AUToscale:CHANnels DISPlayed")
KsInfiniiVisionX.write(":AUToscale")
# Between :WMEMory<r>:SAVE commands, wait for IO complete.
# --------------------------------------------------------------------
# Clear all status registers before checking for new events.
KsInfiniiVisionX.write("*CLS")
KsInfiniiVisionX.write(":WMEMory1:SAVE CHANnel1")
wait_io_operation()
KsInfiniiVisionX.write(":WMEMory2:SAVE CHANnel2")
wait_io_operation()