Setting I/O Timeout
I/O timeout determines how long the system waits for a response from the
interface or peripheral device each time an I/O operation is initiated. If the
timeout limit is exceeded, the operation is aborted and a timeout error is
returned. The default timeout is set to 0 which disables timeout errors.
If timeout is disabled (zero) and an error condition occurs that prevents
successful completion of a data transfer or other I/O operation, the calling
program may hang. Therefore, use of a non-zero timeout value is strongly
recommended as good programming practice. To set or change the timeout use
io_ timeout_ctl as follows:
#include <fcntl.h>
#include <errno.h>
mainO
{
}
int
eid;
long time;
if «eid
=
open(II/dev/raw_hpib
ll
,
O_RDWR»
==
-1) {
printf("open failed, errno
=
%d\n", errno);
exit (2) ;
}
io_reset(eid);
time
=
1000000;
/*set timeout of 1 second*/
/*data transfers using "eid" are controlled by the
timeout value "time"*/
eid is the entity identifier associated with the open interface file, and time is a
32-bit long integer specifying the length of the timeout in microseconds.
Each time an I/O operation is initiated, timeout is restarted. For example,
when setting up bus addressing, the system allows timeout microseconds for
completion. Each subsequent data transfer (in or out) is given the same time
limit. If a given operation is not completed within the time limit specified by
the timeout value, the operation is aborted and an error indication is returned
(return value of
-1)
and errno is set to EIO (not to be confused with EOI).
2-16
General-Purpose Routines