Opening a Session

To access any of the VISA resources, call viOpenDefaultRM() to get a reference to the default Resource Manager. Your application can then use the session viOpenDefaultRM() returns to open sessions to resources controlled by that Resource Manager, as shown in the following example.

 C example

 Visual Basic example

As shown in this example, you use the viOpen() call to open new sessions. In this call, you specify which resource to access by using a string that describes the resource. Refer to VISA Resource Syntax and Examples for resource string and example syntax.

Refer to NI-VISA Platform-Specific and Portability Issues for help in determining exactly which resource you may be accessing. In some cases, such as serial (ASRL) resources, the naming conventions with other serial naming conventions may be confusing. For example, on Windows, COM1 corresponds to ASRL1, unlike in LabVIEW, where COM1 is accessible using port number 0.

The tables in VISA Resource Syntax and Examples show the canonical resource name formats. NI-VISA also supports the use of aliases to make opening devices easier. On Windows, launch Measurement & Automation Explorer (MAX) and choose the menu option Tools»NI-VISA»Alias Editor to manage your aliases. On UNIX, run visaconf and double-click any resource to bring up a dialog box to manage the alias. NI-VISA supports alias names that include letters, numbers, and underscores. To use an alias in your program, call viOpen() with the alias name.