2.4.5.3. - GPIB (IEEE-488) Hardware Functions
GPIB functions are available if the appropriate hardware
and software drivers have been installed on the computer.
Information in the
config
file describes the particular GPIB hardware in use.
Refer to the
Administrator's Guide
for information on the supported GPIB controllers and
how to install the corresponding drivers.
spec allows up to four GPIB controllers to be in use at once.
The controller unit numbers are set in the
config
file.
For the functions below, there are two methods by which the unit
number can be specified.
If no unit number is specified, the default, unit 0, is used.
The first method of addressing is of the form
"unit:addr" where the quotes are required.
Alternatively, the unit number can be
coded in the GPIB address as
unit × 100 + addr.
gpib_get(addr)-
Returns a string from the GPIB device with address
addr.
The device must terminate the string with either a newline (\n) or a carriage return and a newline (\r\n). In either case, the terminator is removed before the string is returned.
At most, 8,192 characters can be read at a time. (That limit is
as of spec release 4.05.09 - the limit was 512 from release 4.05.02
and 255 since release 2.14.)
gpib_get(addr, n)-
As above, but reads
n
bytes and does not look for or remove
the terminator.
gpib_get(addr, s)-
As above, but tries to read up to the terminator given by the
first character of the string
s,
except for the special cases described below.
The terminator is removed.
gpib_get(addr, mode)-
If
mode
is the string
"byte", reads and returns one unsigned binary byte.
The following modes read short or long integers and work the same
on both
big-endian
and
little-endian
platforms.
If
mode
is the string
"int2" reads two binary
bytes and returns the short integer so formed.
If
mode
is the string
"int4" reads four binary
bytes and returns the long integer so formed.
By default, the incoming data is treated as
big endian.
If the incoming data is
little endian,
use
"int2_swap" or
"int4_swap".
gpib_put(addr, string)-
Writes the string
string
to the device with GPIB address
addr.
Returns the number of bytes written.
The length of the string is not limited, but null bytes cannot be sent.
gpib_poll(addr)-
Returns the serial-poll status from the device with address
addr.
gpib_cntl(addr, cmd)-
Performs the selected GPIB command on the device with address
addr.
The string
cmd
is one of the following:
"gtl" - Go to local.
"llo" - Local lockout.
"sdc" - Selected device clear.
"dcl" - Device clear (sent to all devices).
"get" - Group execute trigger (sent to addressed device).
"responsive" - This special command
will return a nonzero value if the GPIB controller (not device)
associated with
addr
is present in spec's configuration file and responds to spec's
presence test.
Returns zero if command is sent successfully,
Otherwise returns -1.
|