Criterr.asm (microsoft c & turbo c) – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 77

8E. Microsoft C
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-62
Personal488 User’s Manual, Rev. 3.0
receive buffer,
chars
. This means
chars
must be an array of known size, for example,
char chars[256]
, not
char*chars
.
•
IEEEPRTF
and
IEEESCNF
are IEEE 488 versions of
PRINTF
and
SCANF
, respectively.
int ieeeprtf(format,...)
char *format
int ieeescnf(format,a,b,c,d,e)
char *format,*a,*b,*c,*d,*e
The
IEEEPRTF
accepts a format string and a list of arguments. It formats its arguments according
to the specified format and sends the formatted string to Driver488/DRV. The
IEEESCNF
accepts
a format string and up to 5 pointers (to the types specified in the format string). It reads a string of
up to 256 bytes from Driver488/DRV, terminates it with a zero, converts it according to the format
string, and places the converted values into the variables pointed to by the specified pointers.
•
RAWMODE
sets the file specified by
handle
for “raw mode” I/O.
int rawmode(handle)
int handle
In “raw mode” MS-DOS does not interpret the characters received from the file. In particular,
control-Z
is not taken as end-of-file. “Raw mode” is usually appropriate for IEEE 488
communications because it does not interfere with the transfer of binary data and because it is
much more efficient than “non-raw mode” I/O.
•
IEEEINIT
establishes communications with Driver488/DRV and configures it for use with C.
int ieeeinit()
It first opens the file
IEEE
for both reading and writing and puts the file descriptor into
IEEE
. It
then puts the file into “raw mode”. Driver488/DRV is then initialized by sending the
IOCTL
“BREAK”
and
RESET
commands. Normal output from C is terminated by a new-line (line feed)
character, and returned strings should be terminated by a null, so
EOL OUT LF
and
EOL IN $0
commands are then issued. Finally a
FILL ERROR
command is issued to enable
SEQUENCE - NO
DATA AVAILABLE
error detection. If an error is detected during any of these commands,
IEEEINIT
returns a
-1
, otherwise it returns a zero (
0
).
CRITERR.ASM (Microsoft C & Turbo C)
Normally, when Driver488/DRV detects an error, perhaps due to a syntax error in a command, it
responds with an I/O error to DOS. When this happens, DOS normally issues an
ABORT
,
RETRY
or
IGNORE
message and waits for a response from the keyboard. There is no way for the user’s program
to detect such an error, determine the cause, and take appropriate action. However, DOS does provide
a method of redefining the action to be taken on such a “critical error”.
CRITERR.ASM
contains a
critical error handler that, when invoked, makes it appear to the calling program that some less-critical
error has occurred. The critical error handler is installed by
CRIT_ON()
and removed by
CRIT_OFF()
.The critical error handler is also automatically removed by DOS when the program exits.
The following program fragment demonstrates the use of the critical error handler:
#include “criterr.h”
crit_on(ieee);
if (ieeewt(“output 16;F0X”) == -1) {
printf(“Error writing F0X to device 16, \n”);
crit_off();
ioctl_wt(ieee,"break",5);
ieeewt(“eol out lf\r\n”);
ieeewt(“status\n”);
ieeerd(response);
printf(“status = %s\n”,response);
crit_on(ieee);
}
We must first
#include
the header file with the definitions of the critical error routines. We then
enable critical error trapping with
CRIT_ON
which takes as a parameter the handle of the file for which