Ieeeio.c – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 94

II. SOFTWARE GUIDES - 8. Driver488/DRV
8H. Turbo C
Personal488 User’s Manual, Rev. 3.0
II-79
printf(“Illegal Command\n”);
if (st195 & 0x04)
printf(“No Remote\n”);
if (st195 & 0x08)
printf(“Trigger Overrun\n”);
if (st195 & 0x10)
printf(“Failed Selftest\n”);
}
The action taken depends, of course, on the design of the system, but in this example, simply displaying
a message is adequate.
Finally, after decoding the cause of the
SRQ
, we are ready to re-enable interrupts and return to the main
program:
ieee_cki = cklpint;
IEEEIO.C
The
IEEEIO.C
file contains several useful declarations and functions, many of which have been used
in the
195DEMO
example program. They are:
•
IEEE
is an integer that holds the file descriptor (MS-DOS handle) returned by
OPEN
.
int ieee
•
segment
and
offset
return the 16-bit
segment
and
offset
values that make up a pointer.
int segment(ptr)
void *ptr
int offset(ptr)
void *ptr
The implementation of these functions depends on the memory model being used. In the small
data model, pointers are 16 bits and are exactly the
offset
desired. Here, the
segment
is always
the internal
ds
register value. In the large data model, pointers are 32 bits, one word of which is
the
segment
and the other is the
offset
. For more information on memory models, see the
“Other Languages” Sub-Chapter in this Chapter.
•
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(int handle
chars,chars[],
int size,
int iocall)
#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.” The Turbo C library function
IOCTL
could be used to perform these functions for small-data programs, but it is not compatible
with the large-data models.
•
CKLPINT, IEEE_CKI,
and
IEEE_ISR
are functions and pointers which provide for automatic
interrupt detection and servicing.