viRead

NI-VISA

viRead

Purpose

Reads data from device or interface synchronously.

C Syntax

ViStatus viRead(ViSession vi, ViPBuf buf, ViUInt32 count, ViPUInt32 retCount)

Visual Basic Syntax

viRead&(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

OUT

Location of a buffer to receive data from device.

count

IN

Number of bytes to be read.

retCount

OUT

Number of bytes actually transferred.

Return Values

Completion Codes Description

VI_SUCCESS

The operation completed successfully and the END indicator was received (for interfaces that have END indicators). This completion code is returned regardless of whether the termination character is received or the number of bytes read is equal to count.

VI_SUCCESS_TERM_CHAR

The specified termination character was read but no END indicator was received. This completion code is returned regardless of whether the number of bytes read is equal to count.

VI_SUCCESS_MAX_CNT

The number of bytes read is equal to count. No END indicator was received and no termination character was read.

 

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_OUTP_PROT_VIOL

Device reported an output protocol error during transfer.

VI_ERROR_BERR

Bus error occurred during transfer.

VI_ERROR_INV_SETUP

Unable to start read 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_ASRL_PARITY

A parity error occurred during transfer.

VI_ERROR_ASRL_FRAMING

A framing error occurred during transfer.

VI_ERROR_ASRL_OVERRUN

An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

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 viRead() operation synchronously transfers data. The data read is to be stored in the buffer represented by buf. This operation returns only when the transfer terminates. Only one synchronous read operation can occur at any one time.

Related Topics

INSTR Resource

INTFC Resource

SERVANT Resource

SOCKET Resource

viBufRead

viReadAsync

viReadToFile

viWrite