viWriteAsync

NI-VISA

viWriteAsync

Purpose

Writes data to device or interface asynchronously.

C Syntax

ViStatus viWriteAsync(ViSession vi, ViBuf buf, ViUInt32 count, ViPJobId jobId)

Visual Basic Syntax

N/A

Resource Classes

GPIB INSTR, GPIB INTFC, GPIB-VXI INSTR, 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

IN

Location of a data block to be sent to a device.

count

IN

Number of bytes to be written.

jobId

OUT

Job ID of this asynchronous write operation.

Return Values

Completion Codes Description

VI_SUCCESS

Asynchronous write operation successfully queued.

VI_SUCCESS_SYNC

Write 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 write 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 viWriteAsync() operation asynchronously transfers data. The data to be written is 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 a job identifier that you can use with either viTerminate() to abort the operation or with an I/O completion event to identify which asynchronous write 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 viWriteAsync(), 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

viReadAsync

viTerminate

viWaitOnEvent

viWrite