|On this page…|
You can execute a serial poll with the spoll function. In a serial poll, the Controller asks (polls) each addressed Listener to send back a status byte that indicates whether it has asserted the SRQ line and needs servicing. The seventh bit of this byte (the RQS bit) is set if the instrument is requesting service.
The Controller performs the following steps for every addressed Listener:
Refer to Status and Event Reporting for more information on the GPIB bus lines and the RQS bit.
This example shows you how to execute a serial poll for an Agilent® 33120A function generator and a Tektronix® TDS 210 oscilloscope. In doing so, the example shows you how to configure many of the status bits described in Standard Event Status Register:
g1 = gpib('ni',0,1);
Create a GPIB object associated with a Tektronix TDS 210 oscilloscope at primary address 2.
g2 = gpib('ni',0,2);
g1.Timeout = 1; g2.Timeout = 1;
fprintf(g1,'*CLS'); fprintf(g1,'*ESE 32'); fprintf(g1,'*SRE 32');
Configure the oscilloscope to request service when a command error occurs.
fprintf(g2,'*CLS') fprintf(g2,'*PSC 0') fprintf(g2,'*ESE 32') fprintf(g2,'DESE 32') fprintf(g2,'*SRE 32')
Determine if any instrument needs servicing.
spoll([g1 g2]) ans = 
Query the voltage value for each instrument.
Determine if either instrument produced an error due to the preceding query.
out = spoll([g1 g2]);
Because Volt? is an invalid command for the oscilloscope, it is requesting service.
out == [g1 g2] ans = 0 1
Because Volt? is a valid command for the function generator, the value is read back successfully.
volt1 = fscanf(g1) volt1 = +1.00000E-01
However, the oscilloscope read operation times out after 1 second.
volt2 = fscanf(g2) Warning: GPIB: NI: An I/O operation has been canceled, most likely due to a timeout. volt2 = ''
fclose([g1 g2]) delete([g1 g2]) clear g1 g2