This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Perform serial poll on GPIB objects


out = spoll(obj)
out = spoll(obj,val)
[out] = spoll(obj)
[out,statusByte] = spoll(obj)
[out] = spoll(obj,val)
[out,statusByte] = spoll(obj,val)



A GPIB object or an array of GPIB objects.


A numeric array containing the indices of the objects in obj, that must be ready for servicing before control is returned to the MATLAB® Command Window.


The GPIB objects ready for servicing.


The service request (SRQ) line status byte.


out = spoll(obj) performs a serial poll on the instruments associated with obj. out contains the GPIB objects that are ready for servicing. If no objects are ready for servicing, then out is empty.

out = spoll(obj,val) performs a serial poll and waits until the instruments specified by val are ready for servicing. An error is returned if a value specified in val does not match an index value in obj.

Using this syntax, spoll blocks access to the MATLAB Command Window until the objects specified by val are ready for servicing, or a timeout occurs for each object specified by val. The timeout period is specified by the Timeout property.

[out] = spoll(obj) returns the object or an array of objects.

[out,statusByte] = spoll(obj) returns the status byte along with the object or an array of objects.

[out] = spoll(obj,val) returns the object and the value specified in the index value of the object.

[out,statusByte] = spoll(obj,val) returns the status byte along with the object and the value specified in the index value of the object.


If obj is a four-element array and val is set to [1 3], then spoll will block access to the MATLAB Command Window until the instruments connected to the first and third GPIB objects have both asserted their SRQ line, or a timeout occurs.

Example of second output argument:

 g1 = gpib('ni', 0, 1);
 g2 = gpib('ni', 0, 2);
 fopen([g1 g2]);
 out1 = spoll(g1);
 out2 = spoll([g1 g2], 1);
 out3 = spoll([g1 g2], [1 2])
 [out4 statusBytes] = spoll([g1 g2])
 [out5 statusBytes] = spoll([g1 g2], 2)
 fclose([g1 g2]);


Serial polling is a method of obtaining specific information from GPIB objects when they request service. When you perform a serial poll, out contains the GPIB object that has asserted its SRQ line.

If obj is an array of GPIB objects

  • Each element of obj must have the same BoardIndex property value.

  • Each element of obj is polled to determine if the instrument is ready for servicing.

If you specify a second output argument when you call an spoll, full serial poll bytes are returned in addition to the SRQ line status in the second argument.


To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.

Introduced before R2006a

Was this topic helpful?