[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    CFP_IO(3) manual page Table of Contents

Name

cfp_io - get information about an I/O device

Synopsis


#include <cfht/cfht.h>#include <cfht/cfp.h>struct cfp_io *cfp_io(name, data,
type)char *name;struct cfp_io *data;int type;
libcfht.a

Description

The purpose of this function is to provide standardized access to the global I/O configuration file. The file itself makes it possible to change the I/O configuration without recompiling programs or requiring user interaction.

Name is a symbolic name used to look up information about a device. The information will be stored in a structure pointed to by data, with a pointer to the structure being returned. Data is allowed to be NULL, in which case cfp_io() uses internal storage space. Type is used to specify that only one kind of device is allowed. If type is set to -1, then any kind is allowed. Possible types are CFP_CAMAC, CFP_HPIB, and CFP_RS232. Most programs will probably specify a particular type. Making a program generic enough to handle multiple types would be quite difficult since the I/O libraries used are so different.

The structure is defined as follows:


struct cfp_io {
    int type;    /* CFP_HPIB, CFP_RS232, or CFP_CAMAC */
    char file[80];    /* device node name */
    int hpib;    /* HP-IB device address, or -1 */
    int branch;    /* CAMAC branch number, or -1 */
    int crate;    /* CAMAC crate number, or -1 */
    int module;    /* CAMAC module number, or -1 */
};

Type will contain the acquired type of device. CFP_RS232 devices should be controlled with standard tty driver calls. CFP_HPIB devices should be controlled with libhh.a calls. CFP_CAMAC devices should be controlled with libcamac.a calls.

File will contain the name of the special file to be used.

If the device is an HP-IB device, or a CAMAC device controlled through HP-IB, then hpib will be set to the HP-IB device address, else hpib will contain -1. (This is how CAMAC control through RS-232 is distinguished from CAMAC control through HP-IB).

If a CAMAC device is to be controlled through a system crate, branch highway system, then branch and crate will contain valid values, else -1 each. If the device is a CAMAC module and not just a crate or non-CAMAC device, then module will contain a valid number, else -1.

Note that the camac and hpib libraries use this function automatically, so that the only time a program should need to call cfp_io() is for acquiring RS-232 device paths.

Return Value

cfp_io returns a pointer to a struct cfp_io. If an error occurs, NULL is returned.

Errors

If an error has occurred, errno will be set as follows:
[EINVAL]
corrupt name.
[ENOTTY]
wrong type. Type was set to non -1 and did not match the acquired type.
[EIO]
corrupt file.

Note that cfp_getln() is used, and that errno may be set from that internal call.

Environment Variables

CFHTIOCONFIG
location of the "ioconfig" file. Note that the name of this environment variable is programmatically accessed via the CFHT_EIOCONFIG define and the default by the CFHT_IOCONFIG define. USE WITH CAUTION.
(name)
Any name can be overridden by an environment variable of the same spelling. This provides an aliasing mechanism. USE WITH CAUTION.

Files

$CFHTIOCONFIG
I/O configuration override file
$cfhtdir/conf/ioconfig
default I/O configuration file.

See Also

cfp(4) , ioconfig(5) .


Table of Contents