Programmatically Find NI Devices Using LabVIEW

Updated Apr 26, 2022

Environment

Software

  • LabVIEW

Driver

  • System Configuration

When multiple systems it is sometimes useful to programmatically find and search for all the NI devices connected to the system. One method of doing this is to use System Configuration and LabVIEW.
 
This guide will walk through the process of programmatically finding and searching by name for all the NI devices with a step by step process and snippets to give a quick start to the application. Please note that expected results for both methods are shown at the bottom of the page.

To detect all NI devices connected to the system programmatically through LabVIEW:


1. Install NI System Configuration to gain access to the NI System Configuration APIs and VIs in LabVIEW. This can be downloaded from the System Configuration Download Page.
2. Either:
  • Recreate the Block Diagram shown below, or use the LabVIEW snippet below.
  • The code uses the Find Hardware VI to retrieve a list of NI hardware that is connected to the system.

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram. 

3. Use the System Hardware Property Node to select any additional information you would like to be displayed about the connected devices.
  • In the example code, the Property Node is used to retrieve the device's Product Name, Vendor Name, Alias, and whether it's simulated. This information is then built into an array.
 

To search for connected NI devices by name programmatically in LabVIEW:

1. Follow the steps above for programmatically detecting all connected NI devices.
2. Either:
  • Modify the code as shown below, or use the LabVIEW snippet below.


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram. 
 

3. This example is the same as the previous, with an addition of the String Subset function.

  • The Search Devices Control contains a string to be searched. The String Subset function then searches the device's Product Name property and checks whether it contains the Search Devices string. Note: this search is case-sensitive.
 

Detect all NI devices connected to the system programmatically through LabVIEW - Result:
Run the VI. Any connected NI devices will be displayed along with the corresponding information that was selected in step 3.



Search for connected NI devices by name programmatically in LabVIEW - Result:
Run the VI. All connected devices beginning with the name you have entered will be displayed.