Programmatically Check If My cRIO Is Connected via LAN or USB

Updated Feb 16, 2020

Reported In

Hardware

  • cRIO-9030
  • cRIO-9031
  • cRIO-9033
  • cRIO-9035
  • cRIO-9038
  • cRIO-9068
  • cRIO-9067
  • cRIO-9066
  • cRIO-9065
  • cRIO-9064
  • cDAQ-9138
  • cDAQ-9134
  • cDAQ-9133
  • cDAQ-9132
  • cDAQ-9137
  • sbRIO-9651
  • NI-9149

Software

  • LabVIEW Real-Time Module

Operating System

  • NI Linux Real-Time

Issue Details

I am conducting TCP communication between the LabVIEW application on my host PC and my RT target (cRIO/sbRIO/myRIO). I want to change my RT target's IP address in my program, but this isn't possible when the RT target is connected via USB. Is there a way to programmatically check if my RT target is connected to the host PC via LAN or USB?
 

Solution

The IP address issued to the RT target will change depending on how it's connected. For example, when the RT target is connected to the host PC via USB, its IP address will have the format of: 172.22.11.*.
By obtaining the RT target's IP address via property node (as demonstrated in the VI snippet below), it is possible to programmatically check if your RT target is connected via LAN or USB cable.

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.