Example Code

Obtaining a List of Only the COM Ports as VISA Resource Names

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

Overview


This document explains how you can obtain a list of only the COM ports while using VISA Find Resource.vi.

Introduction

You can do this by filtering through the VISA Resource Names returned by VISA Find Resources.vi. In a For loop, use VISA Open to open each resource, then use a Property Node to obtain the Interface Description (Properties » Interface Information » Interface Description). This property details whether a resource is a COM port or an LPT port. Using this information, you can discern which type it is with Match Pattern and a Conditional terminal. Use VISA Close to close the reference.

The below VI snippet shows an example of how to do this.

 

 

Additional Resources

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.