:SYSTem:ERRor:NEXT?

Query Syntax

:SYSTem:ERRor[:NEXT]? [DIAGnostic]

Description

Queries and clears the last entry in the last-in first-out error-message buffer. The :NEXT child command is optional and is not required. The query returns a string having two comma-separated values. The first field is a number written as a string: 'error number,"error message"'.

Repeatedly send this query to clear all errors messages. When the buffer is cleared, the string 0,"No error" is returned. You can use the :SYSTem:ERRor:COUNt? query to return the number of errors in the error-message buffer.

The optional DIAGnostic parameter results in an extension to the "error message" string, separated by a semicolon, that specifies the command that caused the error. In other words, 'error number,"error message; command that caused the error"' is returned by the query instead. This lets you check for errors less often and still be able to identify the commands that cause errors.

Example Program

The following Python code shows one method of reading Infiniium 2026's error buffer. The program generates two errors and then queries them back and prints them to the console. The errors are generated by sending the command :QUACK:LIKEA:DUCK which we all know doesn't exist!

error-count.py

#!python3

"""This program illustrates error count checking in the
Infiniium XR8 oscilloscopes.
"""

# Import modules.
import pyvisa
import sys

# Global variables.
oscilloscope_visa_address = "TCPIP0::localhost::hislip0,4880::INSTR"
timeout = 20000  # 20 seconds.


def exit_program():
    """Exit program."""

    # Close connection to oscilloscope.
    sys.stdout.write("Closing oscilloscope connection.\n")
    Infiniium.write(":SYSTem:GTLocal")  # Unlock GUI.
    Infiniium.clear()  # Clear oscilloscope communications interface.
    Infiniium.close()  # Close communications interface to oscilloscope.
    rm.close()  # Close resource manager.
    print("End of program.")
    sys.exit()


def check_error_count(when):
    """Check error count."""

    num_errors = int(Infiniium.query(":SYSTem:ERRor:COUNt?"))
    if num_errors:
        for _ in range(num_errors):
            error_string = Infiniium.query(":SYSTem:ERRor:NEXT? DIAGnostic").strip()
            print(f"ERROR: {error_string}")

        print(f"Exited because error(s) found when: '{when}'")
        exit_program()


# ==========================================================
# Main program:
# ==========================================================

# Connect and initialize oscilloscope.
rm = pyvisa.ResourceManager("C:\\Windows\\System32\\visa64.dll")
try:
    Infiniium = rm.open_resource(oscilloscope_visa_address)
except Exception:
    print(
        f"Unable to connect to oscilloscope at {oscilloscope_visa_address}. Aborting program."
    )
    sys.exit()

Infiniium.timeout = timeout  # Set global timeout.
Infiniium.clear()  # Clear the instrument bus.
# Lock GUI happens automatically.

# Send incorrect commands.
Infiniium.write(":QUACK:LIKEA DUCK")  # Bad command.
Infiniium.write(":TIMebase:POSition 2.4E10")  # Out of range error.

# Check error count.
check_error_count("End of program")

# Exit program.
exit_program()
		

The output from this program looks like:

2 Infiniium error messages reported:
ERROR: -113,"Undefined header;QUACK<Err>; :QUACK:LIKEA:DUCK"
ERROR: 11,"Instrument Error;Timebase Position is set to limit: Entry was out of range; :TIMebase:POSition 2.4E10"

See Also