spec

Software for Diffraction

2.4.8.8. - 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_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).

"ifc"
Interface clear. This command resets the GPIB bus by sending the IFC message. The address addr is ignored. spec runs the same code sequence with the "ifc" command as it does when it initializes the GPIB controller on start up or on the reconfig command. For most controllers, spec sleeps for some fraction of a second after resetting the bus. Also, for most controllers, spec asserts the REN (remote enable) command after sending IFC.

"responsive"
Not a GPIB command, but returns 1 or 0 indicating whether the associated controller is configured and working. Note, the test is on the controller, not the device. To test controllers other than unit 0, the address syntax for addr is "1:1" or 101 for unit 1, etc. The device address isn't looked at for this option.


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.

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.


Returns zero if command is sent successfully, Otherwise returns -1.