viOpen

NI-VISA

viOpen

Purpose

Opens a session to the specified resource.

C Syntax

ViStatus viOpen(ViSession sesn, ViRsrc rsrcName, ViAccessMode accessMode, ViUInt32 openTimeout, ViPSession vi)

Visual Basic Syntax

viOpen&(ByVal sesn&, ByVal rsrcName$, ByVal accessMode&, ByVal openTimeout&, vi&)

Resource Classes

VISA Resource Manager

Parameters

Name Direction Description

sesn

IN

Resource Manager session (should always be a session returned from viOpenDefaultRM()).

rsrcName

IN

Unique symbolic name of a resource. Refer to the Description section for more information.

accessMode

IN

Specifies the mode by which the resource is to be accessed. Refer to the Description section for valid values. If the parameter value is VI_NULL, the session uses VISA-supplied default values.

openTimeout

IN

Specifies the maximum time period (in milliseconds) that this operation waits before returning an error. This does not set the I/O timeout – to do that you must call viSetAttribute() with the attribute VI_ATTR_TMO_VALUE.

vi

OUT

Unique logical identifier reference to a session.

Return Values

Completion Codes Description

VI_SUCCESS

Session opened successfully.

VI_SUCCESS_DEV_NPRESENT

Session opened successfully, but the device at the specified address is not responding.

VI_WARN_CONFIG_NLOADED

The specified configuration either does not exist or could not be loaded; using VISA-specified defaults.

 

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_NSUP_OPER

The given sesn does not support this operation. This operation is supported only by a Resource Manager session.

VI_ERROR_INV_RSRC_NAME

Invalid resource reference specified. Parsing error.

VI_ERROR_INV_ACC_MODE

Invalid access mode.

VI_ERROR_RSRC_NFOUND

Insufficient location information or resource not present in the system.

VI_ERROR_ALLOC

Insufficient system resources to open a session.

VI_ERROR_RSRC_BUSY

The resource is valid, but VISA cannot currently access it.

VI_ERROR_RSRC_LOCKED

Specified type of lock cannot be obtained because the resource is already locked with a lock type incompatible with the lock requested.

VI_ERROR_TMO

A session to the resource could not be obtained within the specified openTimeout period.

VI_ERROR_LIBRARY_NFOUND

A code library required by VISA could not be located or loaded.

VI_ERROR_INTF_NUM_NCONFIG

The interface type is valid, but the specified interface number is not configured.

VI_ERROR_MACHINE_NAVAIL

The remote machine does not exist or is not accepting any connections. If the NI-VISA server is installed and running on the remote machine, it may have an incompatible version or may be listening on a different port.

VI_ERROR_NPERMISSION

Access to the remote machine is denied.

Description

The viOpen() operation opens a session to the specified resource. It returns a session identifier that can be used to call any other operations of that resource. The address string passed to viOpen() must uniquely identify a resource. Refer to VISA Resource Syntax and Examples for the syntax of resource strings and examples.

For the parameter accessMode, the value VI_EXCLUSIVE_LOCK (1) is used to acquire an exclusive lock immediately upon opening a session; if a lock cannot be acquired, the session is closed and an error is returned. The value VI_LOAD_CONFIG (4) is used to configure attributes to values specified by some external configuration utility. Multiple access modes can be used simultaneously by specifying a bit-wise OR of the values other than VI_NULL. NI-VISA currently supports VI_LOAD_CONFIG only on Serial INSTR sessions.

All resource strings returned by viFindRsrc() will always be recognized by viOpen(). However, viFindRsrc() will not necessarily return all strings that you can pass to viParseRsrc() or viOpen(). This is especially true for network and TCPIP resources.

Related Topics

viClose

viFindRsrc

viOpenDefaultRM

viParseRsrc

VISA Resource Manager

VISA Resource Template