viReadAsync

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Purpose

Reads data from device or interface asynchronously.

C Syntax

ViStatus viReadAsync(ViSession vi, ViPBuf buf, ViUInt32 count, ViPJobId jobId)

Visual Basic Syntax

N/A

Resource Classes

GPIB INSTR, GPIB INTFC, Serial INSTR, TCPIP INSTR, TCPIP SOCKET, USB INSTR, USB RAW, VXI INSTR, VXI SERVANT

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

buf

OUT

Location of a buffer to receive data from device.

count

IN

Number of bytes to be read.

jobId

OUT

Job ID of this asynchronous read operation.

Return Values

Completion Codes Description

VI_SUCCESS

Asynchronous read operation successfully queued.

VI_SUCCESS_SYNC

Read operation performed synchronously.

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_RSRC_LOCKED

Specified operation could not be performed because the resource identified by vi has been locked for this kind of access.

VI_ERROR_QUEUE_ERROR

Unable to queue read operation (usually due to the I/O completion event not being enabled or insufficient space in the session's queue).

VI_ERROR_IN_PROGRESS

Unable to queue the asynchronous operation because there is already an operation in progress.

Description

The viReadAsync() operation asynchronously transfers data. The data read is to be stored in the buffer represented by buf. This operation normally returns before the transfer terminates.

Before calling this operation, you should enable the session for receiving I/O completion events. After the transfer has completed, an I/O completion event is posted.

The operation returns jobId, which you can use with either viTerminate() to abort the operation, or with an I/O completion event to identify which asynchronous read operation completed. VISA will never return VI_NULL for a valid jobID.

Note  If you have enabled VI_EVENT_IO_COMPLETION for queueing (VI_QUEUE), for each successful call to viReadAsync(), you must call viWaitOnEvent() to retrieve the I/O completion event. This is true even if the I/O is done synchronously (that is, if the operation returns VI_SUCCESS_SYNC). If you are using LabVIEW, this is done for you automatically.


Related Topics

INSTR Resource

INTFC Resource

SERVANT Resource

SOCKET Resource

VI_EVENT_IO_COMPLETION

viEnableEvent

viRead

viTerminate

viWaitOnEvent

viWriteAsync

WAS THIS ARTICLE HELPFUL?

Not Helpful