Example 3: Asynchronous I/O - National Instruments NI-488.2M Software Reference Manual

For os/2
Hide thumbs Also See for NI-488.2M:
Table of Contents

Advertisement

Application Examples

Example 3: Asynchronous I/O

This example illustrates how an application conducts data transfers with a GPIB
device and immediately returns to perform other non-GPIB related tasks while
GPIB I/O is occurring in the background. This asynchronous mode of operation
is particularly useful when the requested GPIB activity may take some time to
complete.
In this example, a research biologist is trying to obtain accurate CAT scans of a
lab animal's liver. She will print out a color copy of each scan as it is acquired.
The entire operation is computer controlled. The CAT scan machine sends the
images it acquires to a computer connected to a GPIB color printer and fitted
with the NI-488.2M software package. The biologist is familiar with the
command set of her color printer, as described in the user manual provided by the
manufacturer. She acquires and prints images with the aid of an application
program she wrote using high-level GPIB commands. The following steps
correspond to the program flowchart in Figure 2-3.
1.
The application initializes the GPIB by bringing the interface board in the
computer online.
2.
An image is scanned in.
3.
The application sends the GPIB printer a command to print the new image
and immediately returns without waiting for the I/O operation to be
completed.
4.
The application saves the image obtained to a file.
5.
The application inquires as to whether the printing operation has completed
by issuing a GPIB wait command. If the status reported by the wait
command indicates completion (CMPL is in the status returned) and more
scans need to be acquired, Steps 2 through 5 are repeated until the scans have
all been acquired. If the status reported by the wait command in Step 5 does
not indicate that printing is finished, statistical computations are performed
on the scan obtained and Step 5 is repeated.
6.
As a cleanup step before exiting, the application returns the interface board
back to its original state by taking it offline.
NI-488.2M SRM for OS/2
2-6
© National Instruments Corp.
Chapter 2

Advertisement

Table of Contents
loading

Table of Contents