Example Code

Check If A USB Stick Is Present On Your CompactRIO Controller

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 Real-Time Module
  • LabVIEW

Code and Documents

Attachment

Description

Overview

This example demonstrates how to check if a USB stick is connected to a Compact RIO real-time target.

 

Description

The cRIO controllers have a feature for data safety which enables them to switch from saving to a USB storage device, to their internal memory. If you are storing data to your USB storage device and suddenly remove it, the controller will create a folder named U (the same as the drive letter of the USB) and continue storing data there. In order to avoid this, or make sure that you only store data if the USB device is present, you can use this attached code in parallel or preferrably periodically with your code. You can use it as part of your decision making process on whether to start (or continue) logging or not.

 

Requirements

 Software

  • LabVIEW Full or Professional Development System 2012 (or compatible)
  • LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • Compact RIO with USB port (e.g. 9024 or compatible)

 

Steps to Implement or Execute Code

  1. Download and extract the attached file "Check USB stick on real-time target LV2012 NIVerified.zip"
  2. Open project file and follow the instructions in Front Panel and Block Diagram of "Check USB stick on real-time target LV2012 NIVerified.vi" and run the program.

 

Additional Information or References

Check USB stick on real-time target LV2012 NIVerified.vi - Front Panel.png

 

Check USB stick on real-time target LV2012 NIVerified.vi - Block Diagram.png

 

Note: This example was created to be used on VxWorks real-time targets. If running this example on NI Linux Real-Time targets you might have to use different paths as described in the Working with File Paths on Real-Time Targets tutorial.

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

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