7. instrument error checking -九游官网下载
instrument error checking (further referred to as error checking) is the second most important aspect of your remote-control application. the goal of error checking is to assure error-free communication with your instrument, so that all desired settings have been correctly performed, and the measurement results obtained have been acquired using the desired settings.
a part of the instrument status subsystem is a error messages buffer called error queue. if you, for example, send a scpi command that the instrument does not recognize, it generates a new entry in the error queue. error queue has a finite length, usually 10 entries and the oldest entry is discarded to make space for a new one.
explained in chapter measurement sychronization, the status byte contains bit 2 - error message available. to find out whether the error queue is empty, query the *stb? bit 2. if its value is 0, continue further with no additional actions. otherwise, use the scpi query system:error?. the instrument returns the last generated error e.g. -113,”undefined header”. at the same time, this entry is deleted from the error queue. to read all the entries, you need to call the system:error? in a loop until you receive the response 0,”no error” indicating that there are no more errors pending.
the following visa trace shows error checking in action:
- the first command '*rst' is sent correctly, resulting in no error being generated.
- the second command '*rsat' is misspelled, which generates -113, "undefined header" error. the syst:err? query is sent in a loop until the response is 0,"no error".