gpib函数
5. GPIB protocol
5.1. GPIB command bytes
The meaning and values of the possible GPIB command bytes are as follows:
Table 12. GPIB command bytes
byte value name description
(hexadecimal)
0x1 GTL Go to local
0x4 SDC Selected device clear
0x5 PPConfig (also 'PPC' on Parallel poll configure
non-powerpc
architectures)
0x8 GET Group execute trigger
0x9 TCT Take control
0x11 LLO Local lockout
0x14 DCL Device clear
0x15 PPU Parallel poll unconfigure
0x18 SPE Serial poll enable
0x19 SPD Serial poll disable
0x20 to 0x3e MLA0 to MLA30 My (primary) listen
address 0 to 30
0x3f UNL Unlisten
0x40 to 0x5e MTA0 to MTA30 My (primary) talk
address 0 to 30
0x5f UNT Untalk
0x60 to 0x6f MSA0 to MSA15, also When following a talk or
PPE listen address, this is
'my secondary address'
0 to 15. When following
a parallel poll configure,
this is 'parallel poll
enable'. For parallel poll
enable, the least
significant 3 bits of the
command byte specify
which DIO line the
device should use to
send its parallel poll
response. The fourth
least significant bit (0x8)
indicates the 'sense' or
polarity the device
should use when
responding.
0x70 to 0x7d MSA16 to MSA29, also When following a talk or
PPD listen address, this is
'my secondary address'
16 to 29. When following
a parallel poll configure,
this is 'parallel poll
disable'.
0x7e MSA30 My secondary address
30
5.2. GPIB bus lines
Physically, the GPIB bus consists of 8 data lines, 3 handshaking lines, and 5
control lines (and 8 ground lines). Brief descriptions of how they are used
follow:
Table 13. GPIB bus lines
bus line description pin number
DIO1 through DIO8 Data input/output bits. These 8 DIO1 to DIO4 use
lines are used to read and write pins 1 to 4, DIO5 to
the 8 bits of a data or command DIO8 use pins 13
byte that is being sent over the to 16
bus.
EOI End-or-identify. This line is 5
asserted with the last byte of
data during a write, to indicate
the end of the message. It can
also be asserted along with the
ATN line to conduct a parallel
poll.
DAV Data valid. This is a 6
handshaking line, used to signal
that the value being sent with
DIO1-DIO8 is valid. During
transfers the DIO1-DIO8 lines
are set, then the DAV line is
asserted after a delay called the
'T1 delay'. The T1 delay lets the
data lines settle to stable values
before they are read.
NRFD Not ready for data. NRFD is a 7
handshaking line asserted by listeners to indicate they are not ready to receive a new data byte.
NDAC Not data accepted. NDAC is a 8
handshaking line asserted by listeners to indicate they have
not yet read the byte contained on the DIO lines.
IFC Interface clear. The system 9
controller can assert this line (it should be asserted for at least 100 microseconds) to reset the bus and make itself
controller-in-charge.
SRQ Service request. Devices on the 10
bus can assert this line to request service from the
controller-in-charge. The
controller can then poll the devices until it finds the device requesting service, and perform whatever action is necessary.
ATN Attention. ATN is asserted to 11
indicate that the DIO lines contain a command byte (as
opposed to a data byte). Also, it is asserted with EOI when conducting parallel polls.
REN Remote enable. Asserted by the 17
system controller, it enables devices to enter remote mode. When REN is asserted, a device will enter remote mode when it is addressed by the controller. When REN is false, all devices will immediately return to local mode.
ibwrt
Name
ibwrt -- write data bytes (board or device)
Synopsis
class=FUNCSYNOPSISINFO
#include
int ibwrt(int ud, const void *data, long num_bytes);
Description
ibwrt() is used to write data bytes to a device or board. The argument ud can be either a device or board descriptor. num_bytes specifies how many bytes are written from the user-supplied array data. EOI may be asserted with the last byte sent or when the end-of-string character is sent (see ibeos() and
ibeot()). The write operation may be interrupted by a timeout (see ibtmo()), the
board receiving a device clear command, or receiving an interface clear. If ud is a device descriptor, then the library automatically handles addressing the device as listener and the interface board as talker, before sending the data bytes onto the bus.
If ud is a board descriptor, the board simply writes the data onto the bus. The controller-in-charge must address the board as talker.
After the ibwrt() call, ibcnt and ibcntl are set to the number of bytes written. Return value
The value of ibsta is returned.
ibdev
Name
ibdev -- open a device (device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibdev(int board_index, int pad, int sad, int timeout, int send_eoi, int eos);
Description
ibdev() is used to obtain a device descriptor, which can then be used by other functions in the library. The argument board_index specifies which GPIB interface board the device is connected to. The pad and sad arguments specify the GPIB address of the device to be opened (see ibpad() and ibsad()). The
timeout for io operations is specified by timeout (see ibtmo()). If send_eoi is
nonzero, then the EOI line will be asserted with the last byte sent during writes
ibeot()). Finally, the eos argument specifies the end-of-string character (see
and whether or not its reception should terminate reads (see ibeos()).
Return value
If sucessful, returns a (non-negative) device descriptor. On failure, -1 is returned.
ibcnt and ibcntl
Name
ibcnt and ibcntl -- hold number of bytes transferred, or errno Synopsis
class=PROGRAMLISTING
#include
volatile int ibcnt;
volatile long ibcntl;
Description
ibcnt and ibcntl are set after IO operations to the the the number of bytes sent or received. They are also set to the value of errno after EDVR or EFSO errors. If you wish to avoid using a global variable, you may instead use ThreadIbcnt() or ThreadIbcntl() which return thread-specific values.
iberr
Name
iberr -- holds error code
Synopsis
class=PROGRAMLISTING
#include
volatile int iberr;
Description
iberr is set whenever a function from the 'traditional' or 'multidevice' API fails with an error. The meaning of each possible value of iberr is summarized in the following table:
Table 1. iberr error codes
constant value meaning
EDVR 0 A system call has failed. ibcnt/ibcntl will be set to the
value of errno.
ECIC 1 Your interface board needs to be controller-in-charge,
but is not.
ENOL 2 You have attempted to write data or command bytes, but
there are no listeners currently addressed.
EADR 3 The interface board has failed to address itself properly
before starting an io operation.
EARG 4 One or more arguments to the function call were invalid.
ESAC 5 The interface board needs to be system controller, but is
not.
EABO 6 A read or write of data bytes has been aborted, possibly
due to a timeout or reception of a device clear
command.
ENEB 7 The GPIB interface board does not exist, its driver is not
loaded, or it is not configured properly.
EDMA 8 Not used (DMA error), included for compatibility
purposes.
EOIP 10 Function call can not proceed due to an asynchronous
IO operation (ibrda(), ibwrta(), or ibcmda()) in progress.
ECAP 11 Incapable of executing function call, due the GPIB board
lacking the capability, or the capability being disabled in
software.
EFSO 12 File system error. ibcnt/ibcntl will be set to the value of
errno.
EBUS 14 An attempt to write command bytes to the bus has timed
out.
ESTB 15 One or more serial poll status bytes have been lost. This
can occur due to too many status bytes accumulating
(through automatic serial polling) without being read.
ESRQ 16 The serial poll request service line is stuck on. This can
occur if a physical device on the bus requests service,
but its GPIB address has not been opened (via ibdev()
for example) by any process. Thus the automatic serial
polling routines are unaware of the device's existence
and will never serial poll it.
ETAB 20 This error can be returned by ibevent(), FindLstn(), or
FindRQS(). See their descriptions for more information.
If you wish to avoid using a global variable, you may instead use ThreadIberr()
which returns a thread-specific value.
ibsta
Name
ibsta -- holds status
Synopsis
class=PROGRAMLISTING
#include
volatile int ibsta;
Description
ibsta is set whenever a function from the 'traditional' or 'multidevice' API is
called. Each of the bits in ibsta has a different meaning, summarized in the
following table:
Table 1. ibsta Bits
bit value meaning used for
(hexadecimal) board/device
DCAS 0x1 DCAS is set when a board board
receives the device clear
command (that is, the SDC
or DCL command byte). It is
cleared on the next
'traditional' or 'multidevice'
function call following
ibwait() (with DCAS set in
the wait mask), or following
a read or write (ibrd(),
ibwrt(), Receive(), etc.). The
DCAS and DTAS bits will
only be set if the event
queue is disabled. The
event queue may be
disabled with ibconfig().
DTAS 0x2 DTAS is set when a board board
has received a device
trigger command (that is,
the GET command byte). It
is cleared on the next
'traditional' or 'multidevice'
function call following
ibwait() (with DTAS in the
wait mask). The DCAS and
DTAS bits will only be set if
the event queue is disabled.
The event queue may be
disabled with ibconfig().
LACS 0x4 Board is currently board
addressed as a listener.
TACS 0x8 Board is currently board
addressed as talker.
ATN 0x10 The ATN line is asserted. board
CIC 0x20 Board is board
controller-in-charge, so it is
able to set the ATN line.
REM 0x40 Board is in 'remote' state. board
LOK 0x80 Board is in 'lockout' state. board
CMPL 0x100 I/O operation is complete. board or device
Useful for determining when an asynchronous io
operation (ibrda(), ibwrta(), etc) has completed.
EVENT 0x200 One or more clear, trigger, board
or interface clear events have been received, and are available in the event queue (see ibevent()). The
EVENT bit will only be set if
the event queue is enabled. The event queue may be enabled with ibconfig().
SPOLL 0x400 If this bit is enabled (see board
ibconfig()), it is set when the board is serial polled. The
SPOLL bit is cleared when the board requests service (see ibrsv()) or you call ibwait() on the board with SPOLL in the wait mask.
RQS 0x800 RQS indicates that the device
device has requested
service, and one or more status bytes are available for reading with ibrsp(). RQS will only be set if you have automatic serial polling enabled (see ibconfig()).
SRQI 0x1000 SRQI indicates that a device board
connected to the board is asserting the SRQ line. It is only set if the board is the controller-in-charge. If
automatic serial polling is enabled (see ibconfig()),
SRQI will generally be cleared, since when a
device requests service it
will be automatically polled
and then unassert SRQ.
END 0x2000 END is set if the last io board or device
operation ended with the
EOI line asserted, and may
be set on reception of the
end-of-string character. The
IbcEndBitIsNormal option of
ibconfig() can be used to
configure whether or not
END should be set on
reception of the eos
character.
TIMO 0x4000 TIMO indicates that the last board or device
io operation or ibwait() timed
out.
指示上次输入输出操作或者
ibwait()函数超时
ERR 0x8000 ERR is set if the last board or device
'traditional' or 'multidevice'
function call failed. The
global variable iberr will be
set indicate the cause of the
error.
If you wish to avoid using a global variable, you may instead use ThreadIbsta() which returns a thread-specific value. ibask
Name
ibask -- query configuration (board or device) // 质问, 询问, 怀疑, 疑问
Synopsis
class=FUNCSYNOPSISINFO#include int ibask(int ud, int option, int *result);
Description
Queries various configuration settings associated with the board or device
descriptor ud. The option argument specifies the particular setting you wish to
query. The result of the query is written to the location specified by result. To
change the descriptor's configuration, see ibconfig().
Table 1. ibask options
option value result of query used for
(hexadecimal) board/device IbaPAD 0x1 GPIB primary board or device
address
IbaSAD 0x2 GPIB secondary board or device
address (0 for
none, 0x60 to
0x7e for
secondary
addresses 0 to
30)
IbaTMO 0x3 Timeout setting board or device
for io operations
(a number from 0
to 17). See
ibmto().
IbaEOT 0x4 Nonzero if EOI is
asserted with last
byte on writes.
See ibeot().
IbaPPC 0x5 Parallel poll board
configuration.
See ibppc().
IbaREADDR 0x6 Useless, included device
for compatibility
only.
IbaAUTOPOLL 0x7 Nonzero if board
automatic serial
polling is enabled.
IbaCICPROT 0x8 Useless, included board
for compatibility
only.
IbaSC 0xa Nonzero if board board
is system
controller. See ibrsc().
IbaSRE 0xb Nonzero if board board
autmatically
asserts REN line when it becomes the system
controller. See ibsre().
IbaEOSrd 0xc Nonzero if board or device termination of reads on
reception of the end-of-string
character is
enabled. See
ibeos(), in
particular the REOS bit.
IbaEOSwrt 0xd Nonzero if EOI is board or device asserted
whenever
end-of-string
character is sent. See ibeos(), in
particular the XEOS bit.
IbaEOScmp 0xe Nonzero if all 8 board or device bits are used to match
end-of-string
character. Zero if only least
significant 7 bits are used. See ibeos(), in
particular the BIN bit.
IbaEOSchar 0xf The end-of-string board or device byte.
IbaPP2 0x10 Nonzero if in local board
parallel poll configure mode. Zero if in remote
parallel poll
configure mode.
IbaTIMING 0x11 Number board
indicating T1 delay. 1 for 2 microseconds, 2 for 500
nanoseconds, 3 for 350
nanoseconds. The values are declared in the header files as the constants T1_DELAY_2000ns,
T1_DELAY_500ns, and
T1_DELAY_350ns.
IbaReadAdjust 0x13 Nonzero if byte board or device pairs are
automatically swapped during reads.
IbaWriteAdjust 0x14 Nonzero if byte board or device pairs are
automatically swapped during writes.
IbaEventQueue 0x15 Nonzero if event board
queue is enabled.
IbaSPollBit 0x16 Nonzero if the board
use of the SPOLL bit in ibsta is enabled.
IbaSendLLO 0x17 Nonzero if board
devices
connected to this board are
automatically put into local lockout mode when
brought online
with ibfind() or
ibdev().
IbaSPollTime 0x18 Timeout for serial device
polls. The value
of the result is
between 0 and
17, and has the
same meaning as
in ibtmo().
IbaPPollTime 0x18 Timeout for board
parallel polls. The
value of the result
is between 0 and
17, and has the
same meaning as
in ibtmo().
IbaEndBitIsNorm0x1a Nonzero if END board or device al bit of ibsta is set
on reception of
end-of-string
character or EOI.
Zero if END bit is
only set on EOI.
IbaUnAddr 0x1b Nonzero if UNT device
(untalk) and UNL
(unlisten)
commands are
automatically
sent after a
completed io
operation using
this descriptor.
IbaHSCableLengt0x1f Useless, included board h only for
compatibility.
IbaIst 0x20 Individual status board
bit, a.k.a. 'ist'.
IbaRsv 0x21 The current board
status byte this
board will use to
respond to serial
polls.
IbaBNA 0x200 Board index device
(minor number) of
interface board
which is the
controller-in-char
ge of this device's
GPIB bus.
Iba7BitEOS 0x1000 Nonzero if board board
supports 7 bit
EOS
comparisons. See
ibeos(), in
particular the BIN
bit. This is a
Linux-GPIB
extension.
Return value
The value of ibsta is returned.
ibbna
Name
ibbna -- change access board (device) Synopsis
class=FUNCSYNOPSISINFO#include int ibbna(int ud, const char *name);
Description
ibbna() changes the GPIB interface board used to access the device specified
by ud. Subsequent device level calls using the descriptor ud will assume the
device is connected to the interface board specified by name. If you wish to
specify a device's new access board by board index instead of name, you can
use the IbcBNA option of ibconfig().
The name of a board can be specified in the configuration file gpib.conf.
On success, iberr is set to the board index of the device's old access board. Return value
The value of ibsta is returned.
ibcac
Name
ibcac -- assert ATN (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibcac(int ud, int synchronous);
Description
ibcac() causes the board specified by the board descriptor ud to become active controller by asserting the ATN line. The board must be controller-in-change in order to assert ATN. If synchronous is nonzero, then the board will wait for a data byte on the bus to complete its transfer before asserting ATN. If the synchronous attempt times out, or synchronous is zero, then ATN will be asserted immediately.
It is generally not necessary to call ibcac(). It is provided for advanced users who want direct, low-level access to the GPIB bus.
Return value
The value of ibsta is returned.
ibclr
Name
ibclr -- clear device (device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibclr(int ud);
Description
ibclr() sends the clear command to the device specified by ud. Return value
The value of ibsta is returned.
ibcmd
Name
ibcmd -- write command bytes (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibcmd(int ud, const void *commands, long num_bytes);
Description
ibcmd() writes the command bytes contained in the array commands to the
bus. The number of bytes written from the array is specified by num_bytes. The ud argument is a board descriptor, and the board must be controller-in-charge. Most of the possible command bytes are declared as constants in the header files. In particular, the constants GTL, SDC, PPConfig, GET, TCT, LLO, DCL, PPU, SPE, SPD, UNL, UNT,and PPD are available. Additionally, the inline functions MTA(), MLA(), MSA(), and PPE_byte() are available for producing 'my talk address', 'my listen address', 'my secondary address', and 'parallel poll enable' command bytes respectively.
It is generally not necessary to call ibcmd(). It is provided for advanced users who want direct, low-level access to the GPIB bus.
Return value
The value of ibsta is returned.
ibcmda
Name
ibcmda -- write command bytes asynchronously (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibcmda(int ud, const void *commands, long num_bytes);
Description
ibcmda() is similar to ibcmd() except it operates asynchronously. ibcmda() does not wait for the sending of the command bytes to complete, but rather returns immediately.
While an asynchronous operation is in progress, most library functions will fail with an EOIP error. In order to sucessfully complete an asynchronous operation, you must call ibwait() until the CMPL bit is set ibsta. Asynchronous operations may also be aborted with an ibstop() or ibonl() call.
Return value
The value of ibsta is returned.
ibconfig
Name
ibconfig -- change configuration (board or device) Synopsis
class=FUNCSYNOPSISINFO#include int ibconfig(int ud, int option, int setting);
Description
Changes various configuration settings associated with the board or device
descriptor ud. The option argument specifies the particular setting you wish to
modify. The setting argument specifies the option's new configuration. To
query the descriptor's configuration, see ibask().
Table 1. ibconfig options
option value effect used for
(hexadecimal) board/device
IbcPAD 0x1 Sets GPIB board or device
primary address.
Same as ibpad()
IbcSAD 0x2 Sets GPIB board or device
secondary
address. Same
as ibsad()
IbcTMO 0x3 Sets timeout for io board or device
operations. Same
as ibmto().
IbcEOT 0x4 If setting is
nonzero, EOI is
asserted with last
byte on writes.
Same as ibeot().
IbcPPC 0x5 Sets parallel poll board
configuration.
Same as ibppc().
IbcREADDR 0x6 Useless, included device
for compatibility
only.
IbcAUTOPOLL 0x7 If setting is board
nonzero then
automatic serial
polling is enabled.
IbcCICPROT 0x8 Useless, included board
for compatibility
only.
IbcSC 0xa If setting is board
nonzero, board
becomes system
controller. Same
as ibrsc().
IbcSRE 0xb If setting is board
nonzero then
board asserts
REN line.
Otherwise REN is
unasserted.
Same as ibsre().
IbcEOSrd 0xc If setting is board or device
nonzero then
reads are
terminated on
reception of the
end-of-string
character. See
ibeos(), in
particular the
REOS bit.
IbcEOSwrt 0xd If setting is board or device
nonzero then EOI
is asserted
whenever the
end-of-string
character is sent.
See ibeos(), in
particular the
XEOS bit.
IbcEOScmp 0xe If setting is board or device nonzero then all 8 bits are used to match the
end-of-string
character.
Otherwise only the least
significant 7 bits are used. See
ibeos(), in
particular the BIN bit.
IbcEOSchar 0xf Sets the board or device end-of-string
byte. See ibeos().
IbcPP2 0x10 If setting is board
nonzero then the board is put into local parallel poll configure mode, and will not
change its
parallel poll configuration in response to
receiving 'parallel poll enable'
command bytes from the
controller-in-char
ge. Otherwise the
board is put in remote parallel poll configure mode. Some
older hardware does not support local parallel poll configure mode.
IbcTIMING 0x11 Sets the T1 delay. board
Use setting of 1 for 2
microseconds, 2 for 500
nanoseconds, or 3 for 350
nanoseconds.
These values are declared in the header files as the constants T1_DELAY_2000
ns,
T1_DELAY_500n
s, and
T1_DELAY_350n
s. A 2
microsecond T1 delay is safest, but will limit maximum transfer speeds to a few hundred kilobytes per second.
IbcReadAdjust 0x13 If setting is board or device nonzero then byte pairs are
automatically swapped during reads. Presently, this feature is unimplemented.
IbcWriteAdjust 0x14 If setting is board or device nonzero then byte pairs are
automatically swapped during writes. Presently, this feature is unimplemented.
IbcEventQueue 0x15 If setting is board
nonzero then the event queue is enabled. The
event queue is disabled by
default.
IbcSPollBit 0x16 If the setting is board
nonzero then the use of the SPOLL bit in ibsta is enabled.
IbcSendLLO 0x17 If the setting is board
nonzero then
devices
connected to this board are
automatically put into local lockout mode when
brought online with ibfind() or ibdev().
IbcSPollTime 0x18 Sets timeout for device
serial polls. The setting must be
between 0 and 17, which
correspond to the same time
periods as in ibtmo().
IbcPPollTime 0x18 Sets timeout for board
parallel polls. The setting must be between 0 and 17, which
correspond to the same time
periods as in ibtmo().
IbcEndBitIsNorm0x1a If setting is board or device
al nonzero then the END bit of ibsta is set on reception of the
end-of-string
character or EOI (default).
Otherwise END
bit is only set on EOI.
IbcUnAddr 0x1b If setting is device
nonzero then
UNT (untalk) and UNL (unlisten) commands are
automatically sent after a
completed io
operation using this descriptor. This option is off by default.
IbcHSCableLengt0x1f Useless, included board
h only for
compatibility.
IbcIst 0x20 Sets the board
individual status bit, a.k.a. 'ist'. Same as ibist().
IbcRsv 0x21 Sets the current board
status byte this board will use to respond to serial polls. Same as ibrsv().
IbcBNA 0x200 Changes the device
GPIB interface board used to access a device. The setting
specifies the board index of the new access
board. This
configuration option is similar to
ibbna() except the new board is
specified by its board index
instead of a
name.
Return value
The value of ibsta is returned.
ibeos
Name
ibeos -- set end-of-string mode (board or device) Synopsis
class=FUNCSYNOPSISINFO
#include
int ibeos(int ud, int eosmode);
Description
ibeos() is used to set the end-of-string character and mode. The least
significant 8 bits of eosmode specify the eos character. You may also
bitwise-or one or more of the following bits to set the eos mode:
Table 1. End-of-String Mode Bits
constant value (hexadecimal) meaning
REOS 0x400 Enable termination of
reads when eos
character is received.
XEOS 0x800 Assert the EOI line
whenever the eos
character is sent during
writes.
BIN 0x1000 Match eos character
using all 8 bits (instead
of only looking at the 7
least significant bits).
Return value
The value of ibsta is returned.
ibeot
Name
ibeot -- assert EOI with last data byte (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include int ibeot(int ud, int send_eoi);
Description
If send_eoi is non-zero, then the EOI line will be asserted with the last byte
sent by calls to ibwrt() and related functions.
Return value
The value of ibsta is returned.
ibevent
Name
ibevent -- get events from event queue (board) Synopsis
class=FUNCSYNOPSISINFO#include
int ibevent(int ud, short *event);
Description
ibevent() is used to obtain the oldest event stored in the event queue of the board specified by the board descriptor ud. The EVENT bit of ibsta indicates
that the event queue contains 1 or more events. An event may be a clear command, a trigger command, or reception of an interface clear. The type of event is stored in the location specified by event and may be set to any of the following values:
Table 1. events
constant value description
EventNone 0 The board's event
queue is empty
EventDevTrg 1 The board has received
a trigger command from
the controller-in-charge.
EventDevClr 2 The board has received
a clear command from
the controller-in-charge.
EventIFC 3 The board has received
an interface clear from
the system controller.
Note, some models of
GPIB interface board
lack the ability to report
interface clear events.
The event queue is disabled by default. It may be enabled by a call to ibconfig(). Each interface board has a single event queue which is shared across all processes and threads. So, only one process can retrieve any given event from the queue. Also, the queue is of finite size so events may be lost (ibevent() will return an error) if it is neglected too long. Return value
The value of ibsta is returned.
ibfind
Name
ibfind -- open a board or device (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibfind(const char *name);
Description
ibfind() returns a board or device descriptor based on the information found in the configuration file. It is not required to use this function, since device
ibdev() and the 'board index' (minor number descriptors can be obtained with
in the configuration file) can be used directly as a board descriptor. Return value
If sucessful, returns a (non-negative) board or device descriptor. On failure, -1 is returned.
ibist
Name
ibist -- set individual status bit (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibist(int ud, int ist);
Description
If ist is nonzero, then the individual status bit of the board specified by the board descriptor ud is set. If ist is zero then the individual status bit is cleared. The individual status bit is sent by the board in response to parallel polls. On success, iberr is set to the previous ist value.
Return value
The value of ibsta is returned.
ibln
Name
ibln -- check if listener is present (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibln(int ud, int pad, int sad, short *found_listener);
Description
ibln() checks for the presence of a device, by attempting to address it as a listener. ud specifies the GPIB interface board which should check for listeners. If ud is a device descriptor, then the device's access board is used. The GPIB address to check is specified by the pad and sad arguments. pad specifies the primary address, 0 through 30 are valid values. sad gives the secondary address, and may be a value from 0x60 through 0x7e (96 through 126), or one of the constants NO_SAD or ALL_SAD. NO_SAD indicates that no secondary addressing is to be used, and ALL_SAD indicates that all secondary addresses should be checked.
If the board finds a listener at the specified GPIB address(es), then the variable specified by the pointer found_listener is set to a nonzero value. If no listener is found, the variable is set to zero.
The board must be controller-in-charge to perform this function. Also, it must have the capability to monitor the NDAC bus line (see iblines()).
Return value
The value of ibsta is returned.
iblines
Name
iblines -- monitor bus lines (board)
Synopsis
class=FUNCSYNOPSISINFO#include int iblines(int ud, short *line_status);
Description
iblines() is used to obtain the status of the control and handshaking bus lines of
the bus. The board used to monitor the bus is specified by the ud argument,
and the status of the various bus lines are written to the location specified by
line_status.
Some older chips are not capable of reporting the status of the bus lines, so
each line has two corresponding bits in line_status. One bit indicates if the
board can monitor the line, and the other bit indicates the line's state. The
meaning of the line_status bits are as follows: Table 1. line status bits
constant value description
ValidDAV 0x1 The BusDAV bit is valid.
ValidNDAC 0x2 The BusNDAC bit is
valid.
ValidNRFD 0x4 The BusNRFD bit is
valid.
ValidIFC 0x8 The BusIFC bit is valid.
ValidREN 0x10 The BusREN bit is valid.
ValidSRQ 0x20 The BusSRQ bit is valid.
ValidATN 0x40 The BusATN bit is valid.
ValidEOI 0x80 The BusEOI bit is valid.
BusDAV 0x100 Set/cleared if the DAV
line is
asserted/unasserted.
BusNDAC 0x200 Set/cleared if the NDAC
line is
asserted/unasserted.
BusNRFD 0x400 Set/cleared if the NRFD
line is
asserted/unasserted.
BusIFC 0x800 Set/cleared if the IFC
line is
asserted/unasserted.
BusREN 0x1000 Set/cleared if the REN
line is
asserted/unasserted.
BusSRQ 0x2000 Set/cleared if the SRQ
line is
asserted/unasserted.
BusATN 0x4000 Set/cleared if the ATN
line is
asserted/unasserted.
BusEOI 0x8000 Set/cleared if the EOI
line is
asserted/unasserted.
Return value
The value of ibsta is returned.
ibloc
Name
ibloc -- go to local mode (board or device) Synopsis
class=FUNCSYNOPSISINFO
#include
int ibloc(int ud);
Description
Causes the board or device specified by the descriptor ud to go to local mode.
If ud is a board descriptor, and the board is in local lockout, then the function
will fail.
Note, if the system controller is asserting the REN line, then devices on the
bus will return to remote mode the next time they are addressed by the
controller in charge.
Return value
The value of ibsta is returned.
ibonl
Name
ibonl -- close or reinitialize descriptor (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibonl(int ud, int online);
Description
If the online is zero, then ibonl() frees the resources associated with the board or device descriptor ud. The descriptor cannot be used again after the ibonl() call.
If the online is nonzero, then all the settings associated with the descriptor (GPIB address, end-of-string mode, timeout, etc.) are reset to their 'default' values. The 'default' values are the settings the descriptor had when it was first obtained with ibdev() or ibfind().
Return value
The value of ibsta is returned.
ibpad
Name
ibpad -- set primary GPIB address (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibpad(int ud, int pad);
Description
ibpad() sets the GPIB primary address to pad for the device or board specified by the descriptor ud. If ud is a device descriptor, then the setting is local to the descriptor (it does not affect the behaviour of calls using other descriptors, even if they refer to the same physical device). If ud is a board descriptor, then the board's primary address is changed immediately, which is a global change affecting anything (even other processes) using the board. Valid GPIB primary addresses are in the range from 0 to 30.
Return value
The value of ibsta is returned.
ibpct
Name
ibpct -- pass control (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibpct(int ud);
Description
ibpct() passes control to the device specified by the device descriptor ud. The device becomes the new controller-in-charge.
Return value
The value of ibsta is returned.
ibppc
Name
ibppc -- parallel poll configure (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibppc(int ud, int configuration);
Description
Configures the parallel poll response of the device or board specified by ud. The configuration should either be set to the 'PPD' constant to disable parallel poll responses, or set to the return value of the PPE_byte() inline function to
enable and configure the parallel poll response.
After configuring the parallel poll response of devices on a bus, you may use ibrpp() to parallel poll the devices.
Return value
The value of ibsta is returned.
ibrd
Name
ibrd -- read data bytes (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibrd(int ud, void *buffer, long num_bytes);
Description
ibrd() is used to read data bytes from a device or board. The argument ud can be either a device or board descriptor. Up to num_bytes bytes are read into the user-supplied array buffer. The read may be terminated by a timeout occuring(see ibtmo()), the talker asserting the EOI line, the board receiving the end-of-string character (see ibeos()), receiving a device clear command, or
receiving an interface clear.
If ud is a device descriptor, then the library automatically handles addressing the device as talker and the interface board as listener before performing the read.
If ud is a board descriptor, no addressing is performed and the board must be addressed as a listener by the controller-in-charge.
After the ibrd() call, ibcnt and ibcntl are set to the number of bytes read. Return value
The value of ibsta is returned.
ibrda
Name
ibrda -- read data bytes asynchronously (board or device) Synopsis
class=FUNCSYNOPSISINFO#include
int ibrda(int ud, void *buffer, long num_bytes);
Description
ibrda() is similar to ibrd() except it operates asynchronously. ibrda() does not wait for the reception of the data bytes to complete, but rather returns immediately.
While an asynchronous operation is in progress, most library functions will fail
with an EOIP error. In order to sucessfully complete an asynchronous operation, you must call ibwait() until the CMPL bit is set ibsta. Asynchronous operations may also be aborted with an ibstop() or ibonl() call.
Return value
The value of ibsta is returned
ibrdf
Name
ibrdf -- read data bytes to file (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibrdf(int ud, const char *file_path);
Description
ibrdf() is similar to ibrd() except that the data bytes read are stored in a file instead of an array in memory. file_path specifies the save file. If the file already exists, the data will be appended onto the end of the file. Return value
The value of ibsta is returned.
ibrsc
Name
ibrsc -- request system control (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibrsc(int ud, int request_control);
Description
If request_control is nonzero, then the board specified by the board descriptor ud is made system controller. If request_control is zero, then the board releases system control.
The system controller has the ability to assert the REN and IFC lines, and is typically also the controller-in-charge. A GPIB bus may not have more than one system controller.
Return value
The value of ibsta is returned.
ibrsv
Name
ibrsv -- request service (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibrsv(int ud, int status_byte);
Description
The serial poll response byte of the board specified by the board descriptor ud is set to status_byte. If the request service bit (0x40 hexadecimal) in status_byte is set, then the board will also request service by asserting the RQS line.
Return value
The value of ibsta is returned
ibsad
Name
ibsad -- set secondary GPIB address (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibsad(int ud, int sad);
Description
ibsad() sets the GPIB secondary address of the device or board specified by the descriptor ud. If ud is a device descriptor, then the setting is local to the descriptor (it does not affect the behaviour of calls using other descriptors, even if they refer to the same physical device). If ud is a board descriptor, then the board's secondary address is changed immediately, which is a global change affecting anything (even other processes) using the board. This library follows NI's unfortunate convention of adding 0x60 hexadecimal (96 decimal) to secondary addresses. That is, if you wish to set the secondary address to 3, you should set sad to 0x63. Setting sad to 0 disables the use of secondary addressing. Valid GPIB secondary addresses are in the range from 0 to 30 (which correspond to sad values of 0x60 to 0x7e).
Return value
The value of ibsta is returned.
ibsic
Name
ibsic -- perform interface clear (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibsic(int ud);
Description
ibsic() resets the GPIB bus by asserting the 'interface clear' (IFC) bus line for a duration of at least 100 microseconds. The board specified by ud must be the system controller in order to assert IFC. The interface clear causes all devices to untalk and unlisten, puts them into serial poll disabled state (don't worry, you will still be able to conduct serial polls), and the board becomes controller-in-charge.
Return value
The value of ibsta is returned.
ibsre
Name
ibsre -- set remote enable (board)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibsre(int ud, int enable);
Description
If enable is nonzero, then the board specified by the board descriptor ud asserts the REN line. If enable is zero, the REN line is unasserted. The board must be the system controller.
Return value
The value of ibsta is returned.
ibstop
Name
ibstop -- abort asynchronous i/o operation (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibstop(int ud);
Description
ibstop() aborts an asynchronous i/o operation (for example, one started with ibcmda(), ibrda(), or ibwrta()).
The return value of ibstop() is counter-intuitive. On successfully aborting an asynchronous operation, the ERR bit is set in ibsta, and iberr is set to EABO. If
the ERR bit is not set in ibsta, then there was no asynchronous i/o operation in progress. If the function failed, the ERR bit will be set and iberr will be set to some value other than EABO.
Return value
The value of ibsta is returned.
ibtmo
Name
ibtmo -- adjust io timeout (board or device)
Synopsis
class=FUNCSYNOPSISINFO#include
int ibtmo(int ud, int timeout);
Description
ibtmo() sets timeout for IO operations performed using the board or device
descriptor ud. The actual amount of time before a timeout occurs may be
greater than the period specified, but never less. timeout is specified by using
one of the following constants: Table 1. Timeout constants
constant value timeout TNONE 0 Never timeout. T10us 1 10 microseconds T30us 2 30 microseconds T100us 3 100 microseconds T300us 4 300 microseconds T1ms 5 1 millisecond T3ms 6 3 milliseconds T10ms 7 10 milliseconds T30ms 8 30 milliseconds T100ms 9 100 milliseconds T300ms 10 300 milliseconds T1s 11 1 second T3s 12 3 seconds T10s 13 10 seconds T30s 14 30 seconds T100s 15 100 seconds T300s 16 300 seconds T1000s 17 1000 seconds
Return value
The value of ibsta is returned.
ibtrg
Name
ibtrg -- trigger device (device)
Synopsis
class=FUNCSYNOPSISINFO#include int ibtrg(int ud);
Description
ibtrg() sends a GET (group execute trigger) command byte to the device specified by the device descriptor ud. Return value
The value of ibsta is returned.
ibwait
Name
ibwait -- wait for event (board or device) Synopsis
class=FUNCSYNOPSISINFO
#include
int ibwait(int ud, int status_mask);
Description
ibwait() will sleep until one of the conditions specified in status_mask is true.
The meaning of the bits in status_mask are the same as the bits of the ibsta status variable.
If status_mask is zero, then ibwait() will return immediately. This is useful if you
simply wish to get an updated ibsta. Return value
The value of ibsta is returned.
ibwrta
Name
ibwrta -- write data bytes asynchronously (board or device) Synopsis
class=FUNCSYNOPSISINFO#include
int ibwrta(int ud, const void *buffer, long num_bytes);
Description
ibwrta() is similar to ibwrt() except it operates asynchronously. ibwrta() does not wait for the sending of the data bytes to complete, but rather returns immediately.
While an asynchronous operation is in progress, most library functions will fail
with an EOIP error. In order to sucessfully complete an asynchronous
ibwait() and until the CMPL bit is set ibsta. operation, you must call
Asynchronous operations may also be aborted with an ibstop() or ibonl() call.
Return value
The value of ibsta is returned.
ibwrtf
Name
ibwrtf -- write data bytes from file (board or device) Synopsis
class=FUNCSYNOPSISINFO#include
int ibwrtf(int ud, const char *file_path);
Description
ibwrtf() is similar to ibwrt() except that the data to be written is taken from a file
instead of an array in memory. file_path specifies the file, which is written byte for byte onto the bus.
Return value
The value of ibsta is returned.
AllSPoll
Name
AllSPoll -- serial poll multiple devices
Synopsis
class=FUNCSYNOPSISINFO#include
void AllSPoll(int board_desc, Addr4882_t *addressList, short *resultList); void AllSpoll(int board_desc, const Addr4882_t *addressList, short *resultList);
Description
AllSPoll() causes the interface board specified by board_desc to serial poll all the GPIB addresses specified in the addressList array. The results of the serial polls are stored into resultList. If you only wish to serial poll a single device, ReadStatusByte() or ibrsp() may be more convenient.
This function may also be invoked with the alternate capitalization 'AllSpoll' for compatibility with NI's library.
DevClear
Name
DevClear -- clear a device
Synopsis
class=FUNCSYNOPSISINFO#include
void DevClear(int board_desc, Addr4882_t address);
Description
DevClear() causes the interface board specified by board_desc to send the clear command to the GPIB addresses specified by address. The results of the serial polls are stored into resultList. If you wish to clear multiple devices simultaneously, use DevClearList()
DevClearList
Name
DevClearList -- clear multiple devices
Synopsis
class=FUNCSYNOPSISINFO#include
void DevClearList(int board_desc, const Addr4882_t addressList[]);
Description
DevClear() causes the interface board specified by board_desc to send the clear command simultaneously to all the GPIB addresses specified by the addressList array. If addressList is empty or NULL, then the clear command is sent to all devices on the bus. If you only wish to clear a single device, DevClear() or ibclr() may be slightly more convenient.
EnableLocal
Name
EnableLocal -- put devices into local mode.
Synopsis
class=FUNCSYNOPSISINFO#include
void EnableLocal(int board_desc, const Addr4882_t addressList[]);
Description
EnableLocal() addresses all of the devices in the addressList array as listeners then sends the GTL (go to local) command byte, causing them to enter local
mode. This requires that the board is the controller-in-charge. Note that while the REN (remote enable) bus line is asserted, the devices will return to remote mode the next time they are addressed.
If addressList is empty or NULL, then the REN line is unasserted and all devices enter local mode. The board must be system controller to change the state of the REN line.
FindLstn
Name
FindLstn -- find devices
Synopsis
class=FUNCSYNOPSISINFO#include
void FindLstn(int board_desc, const Addr4882_t padList[], Addr4882_t resultList[], int maxNumResults);
Description
FindLstn() will check the primary addresses in the padList array for devices. The GPIB addresses of all devices found will be stored in the resultList array. The maxNumResults limits the maximum number of results that will be returned, and is usually set to the number of elements in the resultList array. If more than maxNumResults devices are found, an ETAB error is returned in iberr. The padList should consist of primary addresses only, with no secondary addresses (all possible secondary addresses will be checked as necessary). Your GPIB board must have the capability to monitor the NDAC bus line in order to use this function (see iblines).
FindRQS
Name
FindRQS -- find device requesting service and read its status byte Synopsis
class=FUNCSYNOPSISINFO#include
void FindRQS(int board_desc, const Addr4882_t addressList[], short *status);
Description
FindRQS will serial poll the GPIB addresses specified in the addressList array until it finds a device requesting service. The status byte of the device requesting service is stored in the location specified by status. The addressList array index of the device requesting service is returned in ibcnt. If no device
requesting service is found, an ETAB error is returned in iberr.
PassControl
Name
PassControl -- make device controller-in-charge
Synopsis
class=FUNCSYNOPSISINFO#include
void PassControl(int board_desc, const Addr4882_t address);
Description
PassControl() causes the board specified by board_desc to pass control to the device specified by address. On success, the device becomes the new controller-in-charge.
PPoll
Name
PPoll -- parallel poll devices
Synopsis
class=FUNCSYNOPSISINFO#include
void PPoll(int board_desc, short *result);
Description
PPoll() is similar to the 'traditional' API function ibrpp(). It causes the interface
board to perform a parallel poll, and stores the parallel poll byte in the location specified by result. Bits 0 to 7 of the parallel poll byte correspond to the dio lines 1 to 8, with a 1 indicating the corresponding dio line is asserted. The devices on the bus you wish to poll should be configured beforehand with PPollConfig(). The board must be controller-in-charge to perform a parallel poll.
PPollConfig
Name
PPollConfig -- configure a device's parallel poll response
Synopsis
class=FUNCSYNOPSISINFO#include
void PPollConfig(int board_desc, Addr4882_t address, int dio_line, int line_sense);
Description
PPollConfig() configures the device specified by address to respond to parallel polls. The dio_line (valid values are 1 through 8) specifies which dio line the device being configured should use to send back its parallel poll response. The line_sense argument specifies the polarity of the response. If line_sense is nonzero, then the specified dio line will be asserted to indicate that the 'individual status bit' (or 'ist') is 1. If sense is zero, then the specified dio line will be asserted when ist is zero.
RcvRespMsg
Name
RcvRespMsg -- read data
Synopsis
class=FUNCSYNOPSISINFO#include
void RcvRespMsg(int board_desc, void *buffer, long count, int termination);
Description
RcvRespMsg() reads data from the bus. A device must have already been addressed as talker (and the board as listener) before calling this function. Addressing may be accomplished with the ReceiveSetup() function.
Up to count bytes are read into the array specified by buffer. The termination argument specifies the 8-bit end-of-string character (which must be a value from 0 to 255) whose reception will terminate a read. termination can also be set to the 'STOPend' constant, in which case no end-of-string character will be used. Assertion of the EOI line will always end a read.
You may find it simpler to use the slightly higher level function Receive(), since
it does not require addressing and reading of data to be performed separately. ReadStatusByte
Name
ReadStatusByte -- serial poll a device
Synopsis
class=FUNCSYNOPSISINFO#include
void ReadStatusByte(int board_desc, Addr4882_t address, short *result);
Description
ReadStatusByte() causes the board specified by the board descriptor board_desc to serial poll the GPIB address specified by address. The status byte is stored at the location specified by the result pointer. If you wish to serial poll multiple devices, it may be slightly more efficient to use AllSPoll(). Serial
polls may also be conducted with the 'traditional API' function ibrsp().
ReceiveSetup
Name
ReceiveSetup -- perform receive addressing
Synopsis
class=FUNCSYNOPSISINFO#include
void ReceiveSetup(int board_desc, Addr4882_t address);
Description
ReceiveSetup() addresses the device specified by address as talker, and addresses the interface board as listener. A subsequent RcvRespMsg() call
will read data from the device.
You may find it simpler to use the slightly higher level function Receive(), since
it does not require addressing and reading of data to be performed separately. ResetSys
Name
ResetSys -- reset system
Synopsis
class=FUNCSYNOPSISINFO#include
void ResetSys(int board_desc, const Addr4882_t addressList[]);
Description
ResetSys() has the following effects:
The remote enable bus line is asserted.
An interface clear is performed (the interface clear bus line is asserted for at
least 100 microseconds).
The device clear command is sent to all the devices on the bus. The *RST message is sent to every device specified in the addressList.
Send
Name
Send -- perform send addressing and write data
Synopsis
class=FUNCSYNOPSISINFO#include
void Send(int board_desc, Addr4882_t address, const void *data, long count, int eot_mode);
Description
Send() addresses the device specified by address as listener, then writes data onto the bus. It is equivalent to a SendList() except it only uses a single GPIB
address to specify the listener instead of allowing an array of listeners. SendCmds
Name
SendCmds -- write command bytes onto bus
Synopsis
class=FUNCSYNOPSISINFO#include
void SendCmds(int board_desc, const void *cmds, long count);
Description
SendCmds() writes count command byte onto the the GPIB bus from the array cmds.
It is generally not necessary to call SendCmds(). It is provided for advanced users who want direct, low-level access to the GPIB bus SendDataBytes
Name
SendDataBytes -- write data
Synopsis
class=FUNCSYNOPSISINFO#include
void SendDataBytes(int board_desc, const void *data, long count, int eot_mode);
Description
SendDataBytes() writes data to the bus. One or more devices must have already been addressed as listener (and the board as talker) before calling this function. Addressing may be accomplished with the SendSetup() function.
count bytes are written from the array specified by data. The eot_mode argument specifies how the message should be terminated, and may be any of the following values:
Table 1. eot modes
constant value description
NULLend 0 Do not assert EOI or add
a newline at the end of
the write.
DABend 1 Assert EOI with the last
byte of the write.
NLend 2 Append a newline, and
assert EOI with the
newline at the end of the
write.
You may find it simpler to use the slightly higher level functions Send() or
SendList(), since they does not require addressing and writing of data to be performed separately.
SendIFC
Name
SendIFC -- perform interface clear
Synopsis
class=FUNCSYNOPSISINFO#include
void SendIFC(int board_desc);
Description
SendIFC() resets the GPIB bus by asserting the 'interface clear' (IFC) bus line for a duration of at least 100 microseconds. The board specified by board_desc must be the system controller in order to assert IFC. The interface clear causes all devices to untalk and unlisten, puts them into serial poll disabled state (don't worry, you will still be able to conduct serial polls), and the board becomes controller-in-charge.
SendLLO
Name
SendLLO -- put devices into local lockout mode
Synopsis
class=FUNCSYNOPSISINFO#include
void SendLLO(int board_desc);
Description
SendLLO() asserts the 'remote enable' bus line, then sends the LLO command byte. Any devices currently addressed as listener will be put into RWLS (remote with lockout state), and all other devices will enter LWLS (local with lockout state). Local lockout means the remote/local mode of devices cannot be changed though the devices' front-panel controls. Unasserting the REN line should bring the devices out of lockout state.
The SetRWLS() performs a similar function, except it lets you specifiy which devices you wish to address as listener before sending the LLO command SendSetup
Name
SendSetup -- perform send addressing
Synopsis
class=FUNCSYNOPSISINFO#include
void SendSetup(int board_desc, const Addr4882_t addressList[]);
Description
SendSetup() addresses the devices in addressList as listeners, and addresses the interface board as talker. A subsequent SendDataBytes() call will write data
to the devices.
You may find it simpler to use the slightly higher level functions Send() or
SendList(), since they does not require addressing and writing of data to be performed separately.
SetRWLS
Name
SetRWLS -- put devices into remote with lockout state
Synopsis
class=FUNCSYNOPSISINFO#include
void SetRWLS(int board_desc, const Addr4882_t addressList[]);
Description
SetRWLS() asserts the 'remote enable' bus line, addresses the devices in the addressList array as listeners, then sends the LLO command byte. The
devices addressed as listener will be put into RWLS (remote with lockout state), and all other devices will enter LWLS (local with lockout state). Local lockout means the remote/local mode of devices cannot be changed though the devices' front-panel controls. Unasserting the REN line should bring the devices out of the lockout state.
TestSRQ
Name
TestSRQ -- query state of SRQ bus line
Synopsis
class=FUNCSYNOPSISINFO#include
void TestSRQ(int board_desc, short *result);
Description
TestSRQ() checks the state of the SRQ bus line and writes its state to the
location specified by result. A '1' indicates the SRQ line is asserted, and a '0' indicates the line is not asserted.
Some boards lack the capability to report the status of the SRQ line. In such a case, an ECAP error is returned in iberr.
TestSys
Name
TestSys -- perform self-test queries on devices
Synopsis
class=FUNCSYNOPSISINFO#include
void TestSys(int board_desc, const Addr4882_t addressList[], short results[]);
Description
TestSys() sends the '*TST?' message to all the devices in the addressList array, then reads their responses into the results array. This will cause devices that conform to the IEEE 488.2 standard to perform a self-test and respond with a zero on success. A non-zero response indicates an error during the self-test. The number of devices which responded with nonzero values from their self-tests is returned in ibcnt and ibcntl. If a device fails to respond to the *TST?
query, an error will be flagged in ibsta (this is different than NI's documented
behaviour which is broken).
Trigger
Name
Trigger -- trigger a device
Synopsis
class=FUNCSYNOPSISINFO#include void Trigger(int board_desc, Addr4882_t address);
Description
Trigger() is equivalent to a TriggerList() call with a single address. TriggerList
Name
Trigger -- trigger multiple devices
Synopsis
class=FUNCSYNOPSISINFO#include void TriggerList(int board_desc, Addr4882_t addressList[]);
Description
TriggerList() sends a GET (group execute trigger) command byte to all the devices specified in the addressList array. If no addresses are specified in
addressList then the GET command byte is sent without performing any
addressing.
WaitSRQ
Name
WaitSRQ -- sleep until the SRQ bus line is asserted Synopsis
class=FUNCSYNOPSISINFO#include void WaitSRQ(int board_desc, short *result);
Description
WaitSRQ() sleeps until either the SRQ bus line is asserted, or a timeout (see
ibtmo()) occurs. A '1' will be written to the location specified by result if SRQ was asserted, and a '0' will be written if the function timed out. GetPAD
Name
GetPAD -- extract primary address from an Addr4882_t value Synopsis
class=FUNCSYNOPSISINFO#include
static __inline__ unsigned int GetPAD(Addr4882_t address);
Description
GetPAD() extracts the primary address packed into the Addr4882_t value address.
Return value
The primary GPIB address (from 0 through 30) stored in address. GetSAD
Name
GetSAD -- extract secondary address from an Addr4882_t value Synopsis
class=FUNCSYNOPSISINFO#include
static __inline__ unsigned int GetSAD(Addr4882_t address);
Description
GetSAD() extracts the secondary address packed into the Addr4882_t value address.
Return value
The secondary GPIB address (from 0x60 through 0x7e, or 0 for none) stored in address.
MakeAddr
Name
MakeAddr -- pack primary and secondary address into an Addr4882_t value Synopsis
class=FUNCSYNOPSISINFO#include
static __inline__ Addr4882_t MakeAddr(unsigned int pad, unsigned int sad);
Description
MakeAddr() generates an Addr4882_t value that corresponds to the specified primary address pad and secondary address sad. It does so by putting pad into the least significant byte and left shifting sad up to the next byte. Examples
class=PROGRAMLISTINGAddr4882_t addressList[ 5 ];
addressList[ 0 ] = 5 /* primary address 5, no secondary address */ addressList[ 1 ] = MakeAddr(3, 0); /* primary address 3, no secondary address */
addressList[ 2 ] = MakeAddr(7, 0x70); /* primary address 3, secondary address 16 */
addressList[ 3 ] = MakeAddr(20, MSA(9)); /* primary address 20, secondary address 9 */
addressList[ 4 ] = NOADDR;
Return value
An Addr4882_t value corresponding to the specified primary and secondary GPIB address
MLA
Name
MLA -- generate 'my listen address' command byte Synopsis
class=FUNCSYNOPSISINFO#include uint8_t MLA(unsigned int address);
Description
MLA() returns a 'my listen address' command byte corresponding to the address argument. The address my be between 0 and 30. Return value
The appropriate MLA command byte is returned. MSA
Name
MSA -- generate 'my secondary address' command byte Synopsis
class=FUNCSYNOPSISINFO#include uint8_t MSA(unsigned int address);
Description
MSA() returns a 'my secondary address' command byte corresponding to the address argument. The address my be between 0 and 30. This macro is also
useful for mangling secondary addresses from the 'real' values between 0 and
30 to the range 0x60 to 0x7e used by most of the library's functions.
Return value
The appropriate MSA command byte is returned MTA
Name
MTA -- generate 'my talk address' command byte
Synopsis
class=FUNCSYNOPSISINFO#include
uint8_t MTA(unsigned int address);
Description
MTA() returns a 'my talk address' command byte corresponding to the address
argument. The address my be between 0 and 30.
Return value
The appropriate MTA command byte is returned
PPE_byte
Name
PPE_byte -- generate 'parallel poll enable' command byte
Synopsis
class=FUNCSYNOPSISINFO#include
uint8_t PPE_byte(unsigned int dio_line, int sense);
Description
PPE_byte() returns a 'parallel poll enable' command byte corresponding to the
dio_line and sense arguments. The dio_line (valid values are 1 through 8) specifies which dio line the device being configured should use to send back its parallel poll response. The sense argument specifies the polarity of the response. If sense is nonzero, then the specified dio line will be asserted to indicate that the 'individual status bit' (or 'ist') is 1. If sense is zero, then the specified dio line will be asserted when ist is zero.
Return value
The appropriate PPE command byte is returned ThreadIbcnt and ThreadIbcntl
Name
ThreadIbcnt and ThreadIbcntl -- thread-specific ibcnt and ibcntl values
Synopsis
class=FUNCSYNOPSISINFO#include int ThreadIbcnt(void);
long ThreadIbcntl(void);
Description
ThreadIbcnt() and ThreadIbcntl() return thread-local versions of the global
variables ibcnt and ibcntl.
Return value
The value of ibcnt or ibcntl corresponding to the last 'traditional' or 'multidevice'
function called in the current thread is returned ThreadIberr
Name
ThreadIberr -- thread-specific iberr value Synopsis
class=FUNCSYNOPSISINFO#include int ThreadIberr(void);
Description
ThreadIberr() returns a thread-local version of the global variable iberr.
Return value
The value of iberr corresponding to the last 'traditional' or 'multidevice' function
called by the current thread is returned. ThreadIbsta
Name
ThreadIbsta -- thread-specific ibsta value Synopsis
class=FUNCSYNOPSISINFO#include int ThreadIbsta(void);
Description
ThreadIbsta() returns a thread-local version of the global variable ibsta.
Return value
The value of ibsta corresponding to the last 'traditional' or 'multidevice' function
called by the current thread is returned.
本文档为【gpib函数】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。