Data input and output – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 192

II. SOFTWARE GUIDES - 9. Driver488/SUB
9H. Data Transfers
Personal488 User’s Manual, Rev. 3.0
II-177
two characters are specified, without
EOI
, all the characters up to, but not including, the
Term
input
terminator characters, are returned to the program. However, if both
EOI
and characters are specified,
the following considerations apply:
•
If
EOI
is received, and the complete terminator character sequence has not been received (even if
the first of the two characters has been received), then all the received characters are returned to
the program.
•
If the complete terminator character sequence has been received, with or without
EOI
asserted on
the last character, then only the characters up to but not including the terminator characters are
returned.
•
If only one character is specified for input termination, the complete terminator character sequence
consists of just that one character, but if two characters are specified, then it consists of both
characters, received consecutively.
During normal
Output
, without a specified character count, the
Term
output terminator is appended to
the data before sending the data to the bus devices. During normal
Enter
, the
Term
input terminator
received by Driver488 is stripped off before being returned to the program. See the
Enter
and
Output
commands in the following text, and in “Section III: Command References.”
Data Input and Output
When a program performs data I/O through Driver488, it tells Driver488 where in memory to find or
put the data and the amount of data to transfer. Driver488 handles the actual transfer. The program
sends the address and quantity of data to be transferred, and Driver488 takes care of the details of the
transfer. The program must be able to tell Driver488 where in memory to find the data, that is, it must
be able to provide Driver488 with the actual address of the buffer. In C language, a character array is
usually used at the memory location for the incoming or outgoing data:
char buffer [20];
The following is a typical
EnterX
command:
char buffer [20]
EnterX (dev, buffer, sizeofbuffer, 1, 0L, 0, 0L);
The Driver488
EnterX
command addresses the ADC bus device (
dev
), requests Driver488 to read
20
bytes of data and put the received data in the buffer memory location. This gives Driver488 all the
information it needs to be able to transfer the received data directly into the buffer character array.
Data I/O using the Driver488
OutputX
command is also possible. For instance, suppose the data from
the above example was to be sent to a device called
DAC
. Here, we would use the following command:
OutputX (DAC, buffer, sizeofbuffer, 1, 0L, 0, 0L);
Data I/O is normally performed with terminator detection set to the default values of carriage-return
line-feed (
CR LF
) with end-or-identify (
EOI
). However, it is possible to explicitly specify that the
Enter
should stop on detection of
EOI
only, or on detection of
EOI
or some single character. For
example, to terminate on
EOI
:
term.eoi=1;
term.nChar=0;
EnterX (dev, buffer, sizeofbuffer, 1, &term, 0 0L);
This reads data into the buffer character array until either
20
characters have been received, or
EOI
has
been detected. However, if
EOI
causes the transfer to stop, we may need to know how much data was
received. This information can be obtained by using the
Buffered
command:
N=Buffered(dev)
The number of bytes transferred is read into
N
. This value can now be used to send the read data out to
the device (
dev
), as follows:
OutputN (dev, buffer, N, 1, &term, 0, 0L);
Note that the variable
N
has been used in place of the literal
20
to specify how many bytes to transmit.