viWriteAsync

Agilent VISA.NET

viWriteAsync

Syntax

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

Description

Write data to device asynchronously. This function asynchronously transfers data to a device. The data to be written is in the buffer represented by buf. This function normally returns before the transfer terminates. An I/O Completion event is posted when the transfer is actually completed.

This function returns jobId, which you can use either with viTerminate to abort the operation, or with an I/O Completion event to identify which asynchronous write operation completed.

If you pass VI_NULL as the jobId parameter to the viWriteAsync operation, no jobId will be returned. The value VI_NULL is a reserved jobId and has a special meaning in viTerminate. This option may be useful if only one asynchronous operation will be pending at a given time. If multiple jobs are queued at the same time on the same session, an application can use the jobId to distinguish the jobs, as they are unique within a session.

Programming Tip: Performing multiple asynchronous operations simultaneously: The VISA asynchronous functions viMoveAsync, viReadAsync and viWriteAsync initiate I/O operations to a device on a separate thread which allows the main thread to continue without blocking when doing I/O. VISA allows you to initiate multiple simultaneous asynchronous operations on a single VISA session, but the Agilent IO Libraries Suite allows only a single thread at a time from a given session to access the device. To perform multiple asynchronous operations simultaneously, you can work around this limitation by opening multiple sessions to the device and doing one VISA asynchronous call on each session.

Parameters

Name

Dir

Type

Description

vi

IN

ViSession

Unique logical identifier to a session.

buf

IN

ViBuf

Represents the location of a data block to be sent to device.

count

IN

ViUInt32

Specifies number of bytes to be written.

jobId

OUT

ViPJobId

Represents the location of a variable that will be set to the job identifier of this asynchronous write operation.

Special Value for jobid Parameter

Value

 

 

Description

VI_NULL

 

 

Do not return a job identifier.

Return Values 

Type ViStatus

This is the function return status. It returns either a completion code or an error code as follows.

Completion Codes

Description

VI_SUCCESS

Asynchronous write operation successfully queued.

VI_SUCCESS_SYNC

Write operation performed synchronously.

Error Codes

Description

VI_ERROR_INV_SESSION
VI_ERROR_INV_OBJECT

The given session or object reference is invalid (both are the same value).

VI_ERROR_QUEUE_ERROR

Unable to queue write operation.

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_IN_PROGRESS

Unable to start a new asynchronous operation while another asynchronous operation is in progress.

See Also

viRead, viTerminate, viWrite, viReadAsync