This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Path Directory for USB Drive or SD With NI Real-Time Devices

Updated Feb 14, 2024

Reported In

Hardware

  • Industrial Controller
  • CompactRIO Controller
  • CompactDAQ Controller
  • CompactRIO Single-Board Controller

Operating System

  • LabVIEW Real-Time (NI Linux Real-Time)
  • Phar Lap
  • VxWorks

Issue Details

I want to write/read to an external USB drive or SD Card from my Real-Time CompactRIO, CompactDAQ, or PXI Controller for data logging purposes.
  • How can I achieve this?
  • What directory path should I use?

Solution

When working with USB and SD devices on NI Real-Time (RT) controllers, the first step is to identify the OS of the controller (Phar Lap, VxWorks, and Linux Real-Time). Based on the OS of the controller, the directory path will be defined as follows:
  • When using Phar Lap or VxWorks controllers, you must point to the drive that is enumerated when the USB drive or SD Card is connected. By default, the external drive should be named with the drive letter U: for the first drive, V: for the second, and so on.
  • When using Linux RT controllers, you must use the partition where the USB or SD was mounted. You can use the lsblk command through the Linux terminal (if a monitor and target are connected to your controller) or via SSH to verify the mounting point (directory path). The image shows the lsblk command  executed via SSH:
Screenshot_1.png
The same LabVIEW functions are used for writing to a specific drive in LabVIEW Real-Time as in Windows. The following is an example program that would write to the primary external drive depending on the OS of the RT controller:
 
Code.png

Additional Information

There are additional things to consider when making an application that accesses an external USB drive or SD Card on NI RT targets.
  • The drive must be formatted to a compatible file system for the specific real-time operating system. All NI Real-Time devices support FAT32, and this format is recommended for ease of transfer to Windows. PharLap targets also support Reliance file systems and NI Linux Real-Time targets support ext2 or ext3 file systems.
  • You must follow the file structure conventions of the operating system (ie, forward slashes, colons). See the Working with File Paths on Real-Time Targets for more information on working with file paths for the different real-time operating systems.
  • If you're seeing permission errors after completing the above steps while using an SD card, check to see if the card is set to Read-Only. With most SD cards, the lock direction will be on the front of the card.