viWriteFromFile

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Purpose

Take data from a file and write it out synchronously.

C Syntax

ViStatus viWriteFromFile(ViSession vi, ViString fileName, ViUInt32 count,
ViPUInt32 retCount)

Visual Basic Syntax

viWriteFromFile& (ByVal vi&, ByVal filename$, ByVal count&, retCount&)

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.

fileName

IN

Name of file from which data will be read.

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_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_FILE_ACCESS

An error occurred while trying to open the specified file. Possible reasons include an invalid path or lack of access rights.

VI_ERROR_FILE_IO

An error occurred while accessing the specified file.

VI_ERROR_CONN_LOST

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

Description

This write operation synchronously transfers data. The file specified in fileName is opened in binary read-only mode, and the data (up to end-of-file or the number of bytes specified in count) is read. The data is then written to the device. This operation returns only when the transfer terminates.

This operation is useful for sending data that was already processed and/or formatted.

Special Values for retCount Parameter

Value Action Description

VI_NULL

Do not return the number of bytes transferred.

If you pass VI_NULL as the retCount parameter to the viWriteFromFile() operation, the number of bytes transferred will not be returned. This may be useful if it is important to know only whether the operation succeeded or failed.

Note Note  The retCount parameter always is valid on both success and error.


Related Topics

INSTR Resource

INTFC Resource

SERVANT Resource

SOCKET Resource

viReadToFile

viWrite

WAS THIS ARTICLE HELPFUL?

Not Helpful