Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
30 ratings:
 2.63 out of 5     Rate this Document

Creating the Correct File Path Format for LabVIEW Real-Time Targets



Primary Software:
Primary Software Version: 5.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Compact FieldPoint>>Controllers, Compact FieldPoint>>Controllers, PXI/CompactPCI>>Controllers>>PXI-8146 RT, PXI/CompactPCI>>Controllers>>PXI-8156B RT, PXI/CompactPCI>>Controllers>>PXI-8170 RT, PXI/CompactPCI>>Controllers>>PXI-8186 RT, PXI/CompactPCI>>Controllers>>PXI-8184RT, PXI/CompactPCI>>Controllers>>PXI-8175 RT, PXI/CompactPCI>>Controllers>>PXI-8176 RT, PXI/CompactPCI>>Controllers>>PXI-8196 RT, PXI/CompactPCI>>Controllers>>PXI-8195 RT, PXI/CompactPCI>>Controllers>>PXI-8145 RT, PXI/CompactPCI>>Controllers>>PXIe-8130 RT, PXI/CompactPCI>>Controllers>>PXI-8106 RT

Problem:
I am trying to save a file on my real-time target and need to know what directory to specify for saving the file. What directory do I save the file on to make sure it is saved on the real-time target?

Solution:
Real-time targets use letters to indicate different drives just like a desktop computer. To access a file within the local memory of the real-time target, the path would begin with the C:\ like on your desktop computer. External Compact Flash drives are lettered as D:\ and external USB hard drives are lettered as U:\. If you wish to log data gathered on the real-time target to a file on the same target, you could use the Write to Text File VI in LabVIEW and use C:\[folder name]\[file name] for your File input parameter on the VI. For example, if you wanted to write to the test.txt file in the temp folder it would result in the following path name: C:\temp\test.txt. The picture below shows how to save a text file in the root directory of the target's memory.
Alternatively, if you are trying to access a specific folder on your real-time target you can use the file path of your deployed VI by using the Current VI's Path VI.  You can then use the strip path and build path functions to programmatically navigate to the desired file path.  The file paths shown in the image below are displayed on a NI cRIO-9004 running the Pharlap operating system.



Note: The folder that you specify to write to has to exist on the target drive before you write to it or your VI will not work correctly.

On VxWorks real-time targets, the file path root is actually /c/ (in lower case). If you are building a path to interact with a file on a VxWorks constant, make sure to use this root in your string.

File path constants are able to dynamically change between C:/ and /c/ so they are the preferred method for specifying root directories. File path constants/controls are also able to switch between forward slash (/) and backward slash (\) dynamically based on the system operating system. If you need to use a build or strip path function and are unsure of what root directory or slash structure to use, then use a file path constant for the root directory and then use string to path functions to interact between the different functionalities.

String to path functions are not able to dynamically change the root directory or slash architecture so be mindful when using them.

Related Links:
KnowledgeBase 2KM92E5F: Using FTP to Access and Use the External CompactFlash or USB drive on a Real-Time Controller?

Attachments:





Report Date: 04/02/2008
Last Updated: 02/24/2012
Document ID: 4K1HPA20

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit