Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 70
II. SOFTWARE GUIDES - 8. Driver488/DRV
8E. Microsoft C
Personal488 User’s Manual, Rev. 3.0
II-55
Also, in Microsoft C and Turbo C, the file must be opened in
BINARY
mode so that end-of-line
characters are not translated.
In Microsoft C and Turbo C, the file is opened with the following statement:
ieee=open(“ieee”,O_RDWR | O_BINARY);
which is part of the
IEEEINIT
function contained in
IEEEIO.C
.
IEEEIO.C
supplies several other
useful routines and definitions. These routines and definitions are described later in more detail in
“Interrupt Handling,” an upcoming topic in this Sub-Chapter.
In the above statement, the value returned by
OPEN
and placed into the integer variable
IEEE
, is either
the handle of the opened file, or
-1
if some error has occurred. The
IEEEINIT
routine checks for this
error indication and returns a
-1
if there has been such an error.
Of course, the file descriptor variable name
IEEE
may be changed as desired, but throughout this
manual and the program files,
IEEE
has been used. Once the file is opened, we can send commands
and receive responses from Driver488/DRV.
Normally, when DOS communicates with a file, it checks for special characters, such as
control-Z
which can indicate end-of-file. When communicating with IEEE 488 devices, DOS’s checking would
interfere with the communication. The
RAWMODE
function prevents DOS from checkings for special
characters:
rawmode(ieee);
As an additional benefit, communication with Driver488/DRV is much more efficient when DOS does
not check for special characters.
Driver488/DRV can accept commands only when it is in a quiescent, ready state. While
Driver488/DRV should normally be ready, it is possible that it was left in some unknown state by a
previous program failure or error. In order to force Driver488/DRV into its quiescent state, we use the
IOCTL_WT
function:
ioctl_wt(ieee,"break",5);
This
IOCTL_WT
function is equivalent to the BASIC statement
IOCTL#1,“BREAK”
which sends the
BREAK
command through a “back door” to Driver488/DRV. Driver488/DRV recognizes this “back
door” command regardless of what else it might be doing and resets itself so that it is ready to accept a
normal command. We can then completely reset the Driver488/DRV with the
RESET
command:
ieeewt(“reset\r\n”);
which resets the operating parameters of the Driver488/DRV back to their normal values (those that
were set during system boot by the
DRVR488
DOS command). Notice that the
EOL OUT
terminators
that mark the end of a Driver488/DRV command are reset to carriage return and line feed by the
IOCTL_WT
command. Thus, the
RESET
command must be terminated by both a carriage return (
\r
)
and a line feed (
\n
). As it is more convenient if Driver488/DRV accepts line feed only as the
command terminator, we use the
EOL OUT
command to set the command terminator to just line feed
(
\n
):
ieeewt(“eol out lf\r\n”);
Notice that this command must also be terminated by both a carriage return and a line feed because the
command terminator is not changed until after the
EOL OUT
command is executed.
Character strings in C are normally terminated by a null (an
ASCII 0
). Thus, it is appropriate for
Driver488/DRV to terminate its responses to the program with a null so that the response can be treated
as a normal character string. We can use the
EOL IN
command to configure Driver488/DRV so that it
does provide an ASCII null terminator:
ieeewt(“eol in $0\n”);
Finally, we enable
SEQUENCE - NO DATA AVAILABLE
error detection by setting the
FILL
mode to
ERROR
:
ieeewt(“fill error\n”);