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

8E. Microsoft C
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-56
Personal488 User’s Manual, Rev. 3.0
All the commands discussed so far:
OPEN
,
RAWMODE
,
IOCTL_WT
,
RESET
,
EOL OUT
,
EOL IN
and
FILL
ERROR
are part of the
IEEEINIT
function included in
IEEEIO.C
.
IEEEINIT
returns a zero if these
steps were executed successfully, and a
-1
if some error was encountered. Thus, to accomplish all the
above steps, we just use the following:
#include “ieeeio.h”
#include
if (ieeeinit() == -1) {
printf(“Cannot initialize IEEE system.\n”);
exit(1);
}
The two
INCLUDE
statements provide the program with definitions of the standard I/O and IEEE I/O
functions so they can be referenced by the demo program.
IEEEINIT
is called to initialize the system,
and if it indicates an error (returns a
-1
), we print an error message and exit. If there was no error, we
just continue with the program.
Once everything is reset, we can test the communications and read the Driver488/DRV revision number
with the
HELLO
command:
char response[256];
ieeewt(“hello\n”);
ieeerd(response);
printf(“%s\n”,response);
We first
IEEEWT
the
HELLO
command, then
IEEERD
the response from Driver488/DRV into the
character string response (
IEEEWT
and
IEEERD
are both supplied in
IEEEIO.C
). Finally, we display
the response with a
PRINTF
.
It is not necessary to perform the
HELLO
command, but it is included here as a simple example of
normal communication with Driver488/DRV. Its response is the revision identification of the
Driver488/DRV software:
Driver488 Revision X.X ©199X IOtech, Inc.
We can also interrogate Driver488/DRV for its status:
ieeewt(“status\n”);
ieeerd(response);
printf(“%s\n”,response);
Subsequently, the printed response is similar to the following:
CS21 1 I000 000 T0 C0 P0 OK
The following indicators describe each component of the Driver488/DRV status:
Indicator
Driver488/DRV Status
C
It is in the Controller state.
S
It is the System Controller.
21
The value of its IEEE 488 bus address.
1
An Address Change has occurred.
I
It is idle (neither a talker nor a listener).
0
There is no
ByteIn
available.
0
It is not ready to send a
ByteOut
.
0
Service Request (
SRQ
) is not asserted.
000
There is no outstanding error.
T0
It has not received a bus device
TRIGGER
command (only applicable in the Peripheral
mode).
C0
It has not received a
CLEAR
command (only applicable in the Peripheral mode).
P0
No
CONTINUE
transfer is in progress.
OK
The error message is “OK”.