ReadToFile

IVI Library

Ivi_ReadToFile

Usage

ViStatus Ivi_ReadToFile(ViSession vi, ViChar filename[ ], ViInt32 readNumber_ofBytes, ViInt32 fileAction, ViInt32* returnCount);

Purpose

This function reads data from an instrument using VISA I/O and writes it to a file you specify. Use this function internally in your instrument driver.

The function assumes that the IVI_ATTR_IO_SESSION attribute for the IVI session you specify holds a valid VISA session for the instrument.

The function opens the file in binary mode.

Parameters

Name Type Description
vi ViSession

The ViSession handle that you obtain from Ivi_SpecificDriverNew. The handle identifies a particular IVI session.

filename ViChar[ ]

Specify the pathname of the file from which to write the data. You can specify an absolute pathname, a relative pathname, or a simple filename. The function treats relative pathnames and simple filenames as relative to the current working directory.

If you enter a literal string in this parameter under Windows, be sure to use double backslashes to represent one backslash in the pathname.

readNumber_ofBytes ViInt32

Specify the maximum number of bytes to read from the instrument.

fileAction ViInt32

Specify whether you want the function to append the data it receives from the instrument to an existing file or to create a new file.

Values:

(1) IVI_VAL_TRUNCATE

(2) IVI_VAL_APPEND

(1) Truncate—If the file already exists, delete its contents and write the instrument data to it. If the file does not exist, create it and write the instrument data to it.

(2) Append—If the file already exists, append the instrument data to it. If the file does not exist, create it and write the instrument data to it.

returnCount ViInt32*

Returns the number of bytes the function successfully writes from the file.

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes