beautypg.com

Initialization of the system – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 99

background image

8I. Turbo Pascal

II. SOFTWARE GUIDES - 8. Driver488/DRV

II-84

Personal488 User’s Manual, Rev. 3.0

IOCTL

is equivalent to the

IOCTL#1

BASIC statement that is described in “Section III: Command

References.” Its effect is to cause Driver488/DRV to listen to the program regardless of what state
it was previously in. This is used by

IeeeInit

to reset Driver488/DRV.

IOCTLRead

is equivalent to the

IOCTL$

BASIC function that is described in “Section III:

Command References.” It returns a single character, either

0

or

1

, stating whether (

1

) or not (

0

)

Driver488/DRV has a response to be read by the program. While it is not used in this sample
program, it is included for completeness.

All strings are of type

STRING

which is a 255 character string. Unless more memory is needed,

there is no reason to define strings with fewer than their maximum of 255 characters.

RawMode

is a procedure that tells DOS not to check for control characters when communicating

with the specified

TEXT

file. This greatly improves the efficiency of communicating with

Driver488/DRV.

IeeeComplete

should be called at the end of programs that use Driver488/DRV to close the

IeeeOut

and

IeeeIn

files.

Initialization of the System

Any program using Driver488/DRV must first establish communications with the Driver488/DRV
software driver. In Turbo Pascal (“Turbo”) this is accomplished using

ASSIGN

,

REWRITE

and

RESET

statements. Communication both to and from Driver488/DRV, is required. In Turbo, this means that
two files must be opened, one for input, and one for output. Other languages may allow the same file to
be opened for both input and output. Three file names are allowed:

IEEEOUT

,

IEEEIN

, and

IEEE

. By

convention, they are used for output, input, and both input and output, respectively. But actuality, they
are all the same and any one of them can be used for input, output, or both, depending on the
programming language. Note that, unlike BASIC (refer to the “QuickBASIC” Sub-Chapter in Chapter
8), the

\DEV\

prefix is not used in Turbo Pascal.

In Turbo, the files are opened with the following statements:

VAR IeeeOut, IeeeIn: TEXT;
Assign(IeeeOut,’IeeeOut’); Rewrite(IeeeOut);
Assign(IeeeIn,’IeeeIn’); Reset(IeeeIn);

which are contained in the

IEEEIO

unit initialization procedure.

Of course, the

TEXT

file variable names (

IeeeOut

and

IeeeIn

) may be changed as desired, but

throughout this manual,

IeeeOut

and

IeeeIn

are used.

Once the files are opened, we can tell DOS that they are used for binary communications and that DOS
should not check for control characters. To do this, we use

RawMode

:

RawMode(IeeeOut);
RawMode(IeeeIn);

Now that the files are ready, we can send commands and receive responses from Driver488/DRV.
While Driver488/DRV should normally be in a reset, inactive state, 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 can use the supplied

IOCTL

procedure:

IOCTL; {Invoke IOCTL procedure}

The

IOCTL

procedure 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:

Writeln(IeeeOut,’RESET’);

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).