1.3.14. - CAMAC, GPIB and Serial
Besides the built-in hardware support for moving motors and counting using CAMAC (IEEE-583), GPIB (IEEE-488) and serial (RS-232C) interfaces, spec provides generalized input/output support over these interfaces from the command level.
The
ca_get(device, subaddress)
command will return the contents of the addressed module register (F=0
in the standard
FNA
CAMAC command code),
while
ca_put(data, device, subaddress)
will write the 24-bit value
data
to the addressed module register (F=16).
The
device
argument is the I/O module index from the configuration file and can be
0, 1 or 2.
The CAMAC slot number of the module is set in the configuration file.
The
subaddress
argument is the module's subaddress (the
A
in the
FNA).
spec allows you to send a string of characters to a GPIB instrument at any GPIB address and to read a string of characters from any instrument. When reading characters, spec will accept a string terminated by either a newline or by carriage return--newline, or you can specify the number of bytes to be read. For example, to initialize a particular voltmeter having GPIB address 12, you would issue the command:
1.FOURC> gpib_put(12, "D0R0Z0B0T0K1M0G1X")
2.FOURC>
That instrument might then be read with:
1.FOURC> {k_ohms = gpib_get(12); print k_ohms}
100.024 2.FOURC>
The command
1.FOURC> x = gpib_get(12, 4)
2.FOURC>
would read 4 bytes from device 12 and not look for terminators.
When sending strings using
gpib_put()
, you cannot send null bytes.
Usually a device that requires null lower order bits in a data byte
will ignore the high order (parity) bit.
In this case, you can usually set that highest
bit to avoid sending a null byte.
The
ser_get(device, n)
and
ser_put(device, string)
functions access the serial interface, where
device
is the index from the configuration file and can be 0, 1 or 2.
In
ser_get()
, n
is the most number of bytes to read.
The function will return after reading one line
(terminated by a newline or carriage return) from the device,
even if the number of bytes is less than
n
.
In
ser_put()
, string
contains the characters to be written.