Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 76

II. SOFTWARE GUIDES - 8. Driver488/DRV
8E. Microsoft C
Personal488 User’s Manual, Rev. 3.0
II-61
•
ERRNO
holds the error code for I/O and other errors.
extern int errno;
•
IOCTL_RD
and
IOCTL_WT
are special versions of
IOCTL_IO
which reads and writes to the I/O
control channel of a device.
int ioctl_io(handle,chars,size,iocall)
int handle,
size,
iocall;
char chars[];
#define ioctl_rd(handle,chars,size) \
ioctl_io(handle,chars,size,0x4402)
#define ioctl_wt(handle,chars,size) \
ioctl_io(handle,chars,size,0x4403)
The I/O control channel of a device is read from and written to exactly as the normal (data)
channel is read and written, but the data transferred is not to be treated in the same way. Normally,
the I/O control channel is used to communicate setup and status information regarding the device
without actually transferring any data to or from it. When using Driver488/DRV,
IOCTL_WT
is
used to force Driver488/DRV to be ready to accept a command, and
IOCTL_RD
is used to return
status information from the driver. These functions correspond exactly to the
IOCTL
and
IOCTL$
commands, as described in “Section III: Command References.”
•
CKLPINT, IEEE_CKI,
and
IEEE_ISR
are functions and pointers which provide for automatic
interrupt detection and servicing.
int cklpint()
int _false_()
int (*ieee_cki)() = _false_
void no_op()
void (*ieee_isr)() = no_op
Driver488/DRV signals interrupts, which are enabled with the
ARM
command, by causing the light
pen signal to appear “true.” The
CKLPINT
checks that Driver488/DRV is able to service an
interrupt (the response from
IOCTL_RD
is
0
) and then checks if an interrupt is pending by
checking the light pen status. The
IEEEWT
routine (described below) calls the function pointed to
by
IEEE_CKI
to determine if an
IEEE
interrupt needs to be serviced. The
IEEE_CKI
normally
points to the function
_false_
which always returns zero (
0
). To enable interrupt checking
IEEE_CKI
must be redirected to point to
CKLPINT
. Interrupt checking is disabled by pointing
IEEE_CKI
back to
_false_
. Once an interrupt has been detected,
IEEEWT
calls the interrupt
service routine pointed to by
IEEE_ISR
to service the interrupt. The
IEEE_ISR
initially points to
no_op
, a function that does nothing, but it may be redirected as needed to specify the appropriate
interrupt service routine for each part of a program.
•
_IEEEWT
and
_IEEERD
are very similar to the unbuffered
WRITE
and
READ
routines provided in
the C library.
int _ieeewt(handle,chars)
int handle
char chars[]
int _ieeerd(handle,chars,size)
int handle,
size
char chars[]
#define ieeewt(chars) _ieeewt(ieee,chars)
#define ieeerd(chars) _ieeerd(ieee,chars,sizeof(chars))
The
_IEEEWT
differs from
WRITE
in that it checks for Driver488/DRV interrupts before writing,
determines the number of characters to write by using
STRLEN
, and prints an error message if an
error has occurred during writing. The
_IEEERD
differs from
READ
only in that it prints an error
message if an error has occurred during reading.
IEEEWT
and
IEEERD
(without the leading
underscore) write and read to the file
IEEE
. Notice that
IEEERD
uses
SIZEOF
to determine the
number of characters to read. This only works if
SIZEOF
can determine the number of bytes in the