viWrite

NI-VISA

viWrite

Purpose

Writes data to device or interface synchronously.

C Syntax

ViStatus viWrite(ViSession vi, ViBuf buf, ViUInt32 count, ViPUInt32 retCount)

Visual Basic Syntax

viWrite&(ByVal vi&, ByVal buf$, ByVal count&, retCount&)

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.

retCount

OUT

Number of bytes actually transferred.

Return Values

Completion Codes Description

VI_SUCCESS

Transfer completed.

 

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_NSUP_OPER

The given vi does not support this 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_TMO

Timeout expired before operation completed.

VI_ERROR_RAW_WR_PROT_VIOL

Violation of raw write protocol occurred during transfer.

VI_ERROR_RAW_RD_PROT_VIOL

Violation of raw read protocol occurred during transfer.

VI_ERROR_INP_PROT_VIOL

Device reported an input protocol error during transfer.

VI_ERROR_BERR

Bus error occurred during transfer.

VI_ERROR_INV_SETUP

Unable to start write operation because setup is invalid (due to attributes being set to an inconsistent state).

VI_ERROR_NCIC

The interface associated with the given vi is not currently the controller in charge.

VI_ERROR_NLISTENERS

No-listeners condition is detected (both NRFD and NDAC are unasserted).

VI_ERROR_IO

An unknown I/O error occurred during transfer.

VI_ERROR_CONN_LOST

The I/O connection for the given session has been lost.

Description

The viWrite() operation synchronously transfers data. The data to be written is in the buffer represented by buf. This operation returns only when the transfer terminates. Only one synchronous write operation can occur at any one time.

Related Topics

INSTR Resource

INTFC Resource

SERVANT Resource

SOCKET Resource

viBufWrite

viRead

viWriteAsync

viWriteFromFile