viOpen
Syntax
viOpen(ViSession sesn, ViRsrc rsrcName, ViAccessMode accessMode, ViUInt32 timeout, ViPSession vi);
Description
This function opens a session to the specified device. It returns a session identifier that can be used to call any other functions to that device.
Whether viOpen actually determines the presence of the device opened depends on the Address check property set in Connection Expert for the device. Click here for more information on this interaction.
Parameters
Name |
Dir |
Type |
Description |
sesn |
IN |
ViSession |
Resource Manager session (should always be the Default Resource Manager for VISA returned from viOpenDefaultRM). |
rsrcName |
IN |
ViRsrc |
Unique symbolic name (VISA address) of a resource. (See the following tables.) Can also be a VISA alias (defined in the Agilent Connection Expert utility). |
accessMode |
IN |
ViAccessMode |
Specifies the modes by which the resource is to be accessed. The value VI_EXCLUSIVE_LOCK 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 VI_LOAD_CONFIG value is used to configure attributes specified by some external configuration utility. If this value is not used, the session uses the default values provided by this specification. Multiple access modes can be used simultaneously by specifying a "bit-wise OR" of the values. (Must use VI_NULL in VISA 1.0.) |
timeout |
IN |
ViUInt32 |
If the accessMode parameter requires a lock, this parameter specifies the absolute time period (in milliseconds) that the resource waits to get unlocked before this operation returns an error. Otherwise, this parameter is ignored. (Must use VI_NULL in VISA 1.0.)Note: The timeout parameter affects ONLY the LOCK, it does not impact the overall viOpen command timing. |
vi |
OUT |
ViPSession |
Unique logical identifier reference to a session. |
Address String Grammar for rsrcName Parameter |
|||
Interface |
Syntax |
||
ASRL |
ASRL[board][::INSTR] |
||
GPIB |
GPIB[board]::INTFC |
||
GPIB-VXI |
GPIB-VXI[board]::MEMACC |
||
GPIB |
GPIB[board]::primary address[::secondary address][::INSTR] |
||
GPIB-VXI |
GPIB-VXI[board]::VXI logical address[::INSTR] |
||
GPIB-VXI |
GPIB-VXI[board][::VXI logical address]::BACKPLANE |
||
PXI |
PXI[bus]::device[::function][::INSTR] |
||
PXI |
PXI[interface]::bus-device[.function][::INSTR] |
||
PXI |
PXI[interface]::CHASSISchassis::SLOTslot[::FUNCfunction][::INSTR] |
||
PXI |
PXI[interface]::MEMACC |
||
TCPIP |
TCPIP[board]::host address::port::SOCKET |
||
TCPIP |
TCPIP[board]::host address[::HiSLIP device name[,HiSLIP port]][::INSTR] |
||
TCPIP |
TCPIP[board]::host address[::LAN device name]::INSTR |
||
USB |
USB[board]::manufacturer ID::model code::serial number[::USB interface number][::INSTR] |
||
VXI |
VXI[board]::MEMACC |
||
VXI |
VXI[board]::VXI logical address[::INSTR] |
||
VXI |
VXI[board][::VXI logical address]::BACKPLANE |
||
Examples of Address Strings for rsrcName Parameter |
|||
Address String |
Description |
||
ASRL1::INSTR |
A serial device located on port 1. |
||
GPIB::1::0::INSTR |
A GPIB device at primary address 1 and secondary address 0 in GPIB interface 0. |
||
GPIB2::INTFC |
Interface or raw resource for GPIB interface 2. |
||
GPIB-VXI::9::INSTR |
A VXI device at logical address 9 in a GPIB-VXI controlled VXI system. |
||
GPIB-VXI1::MEMACC |
Board-level register access to GPIB-VXI interface number 1. |
||
"MyDMM" |
A device for which the VISA Alias myDMM has been created in the Agilent Connection Expert utility |
||
PXI0::21::INSTR |
PXI device 21 on bus 0 |
||
PXI0::3-18.2::INSTR |
Function 2 on PXI device 18 on bus 3 |
||
PXI0::3-18::INSTR |
PXI device 18 on bus 3. |
||
PXI0::CHASSIS1::SLOT4::INSTR |
PXI device in slot 4 of chassis 1. |
||
PXI0::MEMACC |
Access to system controller memory available to devices in the PXI system. |
||
TCPIP0::[fe80::1]::hislip0::INSTR |
A TCP/IP device using HiSLIP located at IPv6 IP address fe80::1. |
||
TCPIP::devicename @company.com::INSTR |
TCPIP device using VXI-11 located at the specified address. This uses the default LAN Device Name of inst0. |
||
TCPIP0::1.2.3.4::999::SOCKET |
Raw TCPIP access to port 999 at the specified address. |
||
TCPIP0::[fe80::218:e77f]::999::SOCKET | Raw TCPIP access to port 999 at the specified IPv6 address. | ||
USB::0x1234::0x5678::A22-5::INSTR |
A USB device with manufacturer ID 0x1234, model code 0x5678, and serial number A22-5. This uses the device’s first available USBTMC interface. This is usually number 0. |
||
VXI::1::BACKPLANE |
Mainframe resource for chassis 1 on the default VXI system, which is interface 0. |
||
VXI::MEMACC |
Board-level register access to the VXI interface. |
||
VXI0::1::INSTR |
A VXI device at logical address 1 in VXI interface VXI0. |
Return Values
Type ViStatus |
This is the function return status. It returns either a completion code or an error code as follows. |
Completion Codes |
Description |
VI_SUCCESS |
Operation completed successfully. |
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_ALLOC |
Insufficient system resources to open a session. |
VI_ERROR_INTF_NUM_NCONFIG |
The interface type is valid but the specified interface number is not configured. |
VI_ERROR_INV_ACC_MODE |
Invalid access mode. |
VI_ERROR_INV_RSRC_NAME |
Invalid resource reference specified. Parsing error. |
VI_ERROR_INV_SESSION |
The given session or object reference is invalid (both are the same value). |
VI_ERROR_LIBRARY_NFOUND |
A code library required by VISA could not be located or loaded. |
VI_ERROR_NSUP_OPER |
The given sesn does not support this function. For VISA, this function is supported only by the Default Resource Manager 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_RSRC_NFOUND |
Insufficient location information or resource not present in the system. |
VI_ERROR_TMO |
A session to the resource could not be obtained within the specified timeout period. |
See Also
viClose
Address Check, viFindRsrc, and viOpen