I/o control (ioctl) communication, Ioctl get & set device data, Ioctl read & write – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 116

II. SOFTWARE GUIDES - 8. Driver488/DRV
8K. Other Languages
Personal488 User’s Manual, Rev. 3.0
II-101
I/O Control (IOCTL) Communication
DOS provides several I/O Control (IOCTL) functions that are useful with Driver488/DRV. Two of
these:
IOCTL GetDeviceData
and
IOCTL SetDeviceData
allow Driver488/DRV to be configured
for faster “Raw Mode” communication, while the other two:
IOCTL Read
and
IOCTL Write
, perform
the functions of the BASIC
IOCTL$
function and
IOCTL#1
command, respectively.
IOCTL Get & Set Device Data
When communicating with character devices, DOS normally checks the transferred data for control
characters such as
X-ON
,
X-OFF
and
control-Z
. However when communicating with
Driver488/DRV, this is not desirable. First of all, it might interfere with control characters that are
supposed to be transferred to or from Driver488/DRV. Second, and more importantly, while DOS is
checking for control characters, it only transfers one character at a time to or from Driver488/DRV.
This is much less efficient than transferring large blocks of data. Thus, whenever possible, DOS should
be configured to not check for control characters when communicating with Driver488/DRV. This is
typically accomplished by a function called
RawMode
in the language-specific support files (such as
IEEEIO.C
) provided with Driver488/DRV. The DOS
IOCTL Get and SetDeviceData
functions
are used together to configure Driver488/DRV for
RawMode
(binary) communication as:
mov
AX,4400h
;DOS Get Device Data Function
mov
BX,ieee
;File handle for Driver488/DRV
int
21h
;Execute DOS function
mov
DH,0
;Must clear DH
or
DL,20h
:Set “don’t check for control characters” bit
mov
AX,4401h
;DOS Set Device Data Function
mov
BX,ieee
;File handle
int
21h
;Execute DOS function
The first part of this code fragment reads the current device control settings from DOS. These are
returned in the
DX
register which is then modified to tell DOS not to check for control characters.
Finally, DOS is again called to implement the new control settings. Once the
ieee
file has been
opened and configured for
RawMode
, we are ready to communicate with Driver488/DRV.
IOCTL Read & Write
IOCTL Read
and
IOCTL Write
provide a “back-door” communication channel to Driver488/DRV.
This alternate method of communication is normally used to send special commands (
Write
) and
request status (
Read
) from Driver488/DRV.
Driver488/DRV recognizes only one
IOCTL Write
command:
BREAK
. When
IOCTL Write
is used
to send
BREAK
to Driver488/DRV, it forces Driver488/DRV into a quiescent, ready state in which it is
waiting for a new command. The
BREAK
command also forces the
EOL OUT
terminators to their
default values. Thus Driver488/DRV is reset so that it is ready and able to receive new commands,
regardless of what it was previously doing.
It is recommended that the
BREAK
command be sent before any other Driver488/DRV commands. In
assembly language,
BREAK
may be sent as indicated in the table.
brk
DB
“BREAK”
;BREAK command text
brklen
EQU
$-brk
;Length of BREAK command
mov
AX, 4403h
;IOCTL Write function
mov
BX, ieee
;File handle
mov
CX, brklen
;# chars to send
mov
DX, offset
brk
;DS:DX -> command
int
21h
;Execute DOS function
jc
error
;Check for error
This is identical to the BASIC command
IOCTL
described in “Section III: Command References” of
this manual.
The
IOCTL Read
command is used to receive status from Driver488/DRV. It receives a single ASCII
character, either
0
,
1
,
2
, or
3
. The meaning of each response is: