1462
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
40
Programming Examples
result = InfiniiVision.query("%s" % query)
check_instrument_errors(query)
return result
# =========================================================
# Send a query, check for errors, return floating-point value:
# =========================================================
def do_query_number(query):
if debug:
print "Qyn = '%s'" % query
results = InfiniiVision.query("%s" % query)
check_instrument_errors(query)
return float(results)
# =========================================================
# Send a query, check for errors, return binary values:
# =========================================================
def do_query_ieee_block(query):
if debug:
print "Qys = '%s'" % query
result = InfiniiVision.query_binary_values("%s" % query, datatype='s')
check_instrument_errors(query)
return result[0]
# =========================================================
# Check for instrument errors:
# =========================================================
def check_instrument_errors(command):
while True:
error_string = InfiniiVision.query(":SYSTem:ERRor?")
if error_string:
# If there is an error string value.
if error_string.find("+0,", 0, 3) == -1:
# Not "No error".
print "ERROR: %s, command: '%s'" % (error_string, command)
print "Exited because of error."
sys.exit(1)
else:
# "No error"
break
else:
# :SYSTem:ERRor? should always return string.
print "ERROR: :SYSTem:ERRor? returned nothing, command: '%s'" % comma
nd
print "Exited because of error."
sys.exit(1)
# =========================================================
# Main program:
# =========================================================
rm = visa.ResourceManager("C:\\Windows\\System32\\agvisa32.dll")