Example Programs

Programmatic FTP file transfer

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.

    Hardware

  • CompactRIO|SingleBoardRIO
  • PXI|VXI

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Copies files from a remote NI Real-Time (RT) target to the local host

 

Description

This VI uses FTP  functions to programmatically copy all the files in a directory (user specified) on the real time target to a directory (user specified) in the host PC. The type of each item in the directory in the RT target is first established and only the items of type 'file' are picked. The array containing paths to all these 'file' items is built . This is then built into an array of clusters (which is the data type expected by the 'FTP Retrieve Multiple.vi')

 

Requirements

  • LabVIEW 2012 (or compatible)
  • Any NI embedded RT target (cRIO or PXI controller) with all the necessary software installed 

 

Steps to Implement or Execute Code

  1. Connect an embedded hardware target (cRIO or PXI controller)
  2. Identify the IP address of the target from Measurement and Automation Explorer (MAX)
  3. Enter the IP address of the remote target on the front panel
  4. Enter the path to the directory on the RT target (from which you want to copy files)
  5. Enter the path to the directory on the host PC(to which you want to copy files)
  6. Click on 'Run'
  7. You should find your files copied to the directory on the host PC after the VI finishes execution

 

Additional Information or References VI Block Diagram

VI Block Diagram

file transfer.png 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

  

Thanks and Regards,
Supreeth.K

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

Comments
Member aveo
Member

Hi. I want to transfer files from the host PC to RT target. Any idea how to do it?

Member prajwal.prithviraj
Member

I am also looking for the same i need to transfere the file from host to RT

Member aveo
Member

Hi,

try out the following code for transfering a file from host to RT. Host to RT.png

Member MKsarith
Member

This will not work untill configuring the FTP server in the windows, which is disabled by default.

Member WWST
Member

Thank you, Supreeth, for sharing this very useful vi.

One comment - I was trying to transfer .zip files and though the files were transferred, they could not be opened. When I set the file type to binary (boolean in the last FOR loop set to TRUE), it worked.

Member Supreeth.K
Member

Thanks for the feedback WWST.. you are right the 'false' value works only for ASCII files...

Thanks and Regards,
Supreeth.K

Member dlmille1
Member

In trying to transfer TDMS files, I had to set Active(T) =  False for FTP Directory Listing.vi and FTP Retrieve Multiple.vi to get this to work.

I also Ignore the NI message for "Thanking me for using NI FTP"

Member aro1
Member

Snippet3.JPG

Member aro1
Member

Hi All,

I am trying to programmatically copy files from my PC to my cRIO. The above screen shot is what my block diagram looks like. I ran this routine, I didn't get any error message, however, I didn't see a copy of the file in the folder I specified on the cRIO after I opened it . I have double-checked the filenames and paths, and they are as I want but the copied file isn't showing up on the cRIO. Please can anyone help me solve thi issue?

Member aro1
Member

Please how can I configure the FTP server as you mentioned? I tried to implement "aveo's" routine, I got no errors, but I didn't see the file(s) I "copied" to the cRIO.