beautypg.com

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

Page 75

background image

8E. Microsoft C

II. SOFTWARE GUIDES - 8. Driver488/DRV

II-60

Personal488 User’s Manual, Rev. 3.0

We then Serial Poll the 195 to determine its status. If there were other devices on the bus that could be
generating the

SRQ

, each of them would be have to be checked in turn.

int st195;
ieeewt(“spoll 16\n”);
ieeescnf(“%d”,&st195);
if ((st195 & 0x40) == 0 ) {
printf(“Non-195 SRQ!\n”);
exit();
}

Bit

DIO7

, with a value of

0x40

, is returned as true (

1

) in the Serial Poll response of those devices

requesting service. In our simple example we expect that the 195 is the only possible cause of an

SRQ

,

and if not, there must be some error.

Now that we have identified the device that is requesting service, we can further examine the Serial
Poll status to classify the request:

if ((st195 & 0x20) == 0) {
if (st195 & 0x01)
printf(“Overflow\n”);
if (st195 & 0x02)
printf(“Buffer Full\n”);
if (st195 & 0x04)
printf(“Buffer 1/2 Full\n”);
if (st195 & 0x08)
printf(“Reading Done\n”);
if (st195 & 0x10)
printf(“Busy\n”);
} else {
if (st195 & 0x01)
printf(“Illegal Command Option\n”);
if (st195 & 0x02)
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 on the system design, but in this example, a message display is adequate.
Now, after decoding the cause of the

SRQ

, we can 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.