From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

How to Query Your COM Ports for a Particular Device

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.

    Hardware

  • Other

    Software

  • LabVIEW

    Driver

  • NI VISA

Code and Documents

Attachment

Overview
This example VI can be used to programmatically identify which COM ports are connected on your machine.


Description 

First, the VI identifies each machine that is connected to the COM ports using the *IDN? command. The nested Case Structures in the VI can be used and modified to perform any desired actions based on the acquired information from the COM ports.

Requirements

  1. LabVIEW 2012 or later
  2. NI-VISA Driver

 

Steps to Implement or Execute Code

  1. Specify the Expected COM Port on the Front Panel
  2. Run the VI

 

Additional Information or References

VI Snippet

11111.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Applications Engineer
National Instruments

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