LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programtically transfering files from PC to RT target using FTP

Here's a snippet of a routine I wrote to read the ni-rt.ini file from a remote PXI to my PC.  Note that "Target IP In" is the IP of the Remote RT system, and this code runs on the Host PC.  Works like a charm.

Reading ni-rt.png

Bob Schor

0 Kudos
Message 11 of 19
(1,971 Views)

You could try 2 things, not sure if it helps:

1) use passive mode FTP (i.e. set the active flag to False)

2) leave away the leading \ in the target path (e.g. RT_Datafiles\tst.csv)

 

Passive mode is often preferred since then you only have connections from client to server. Active needs firewall configurations on both ends.

0 Kudos
Message 12 of 19
(1,957 Views)

All,

Yes, I tried copying a file from the RT to my PC, and that worked.

 

Dan_u,

I tried the 2 suggestions you stated, unfortunately I still could not find the "file copied" into the cRIO folder. 

 

Bob_Schor,

Please could you modify your routine by trying to copy a file from PC to the RT target, and then test it to see if if works in the other direction? If it does, please let me know what I may be doing wrong. 

 

0 Kudos
Message 13 of 19
(1,942 Views)

That's also straight-forward.

FTP to Remote.png

I'm writing back to the Remote's ni-rt.ini file, copying the file in "appended path" (not my name, comes from the Snippet).  You might notice that the FTP Put File function is missing the "Required" Default arguments, User "anonymous" and Password "<blank>" -- I got tired of being forced to put in "default" parameters (why create defaults if you are required to enter them?  Fortunately, these functions in VI.lib are not "locked" -- I simply opened them and changed these two parameters to "Recommended" and re-saved them.

 

Bob Schor

0 Kudos
Message 14 of 19
(1,938 Views)

That is similar to what I have, without the connections to the "user" and "password". Did you run the "reversed" routine to verify the files were successfully copied to the cRIO folder specified path? If yes, please could you test the VI file I posted as well to check if that works on your end? Maybe there is something wrong with my "setup".

0 Kudos
Message 15 of 19
(1,930 Views)

Hmm, I probably should have taken a better look at your code earlier, sorry.  It looks OK, but here are two questions that only you can answer:

  1. Is the IP of the Remote (which you have saved in the variable called "Host") 169.254.84.168?  Can you use Windows (or MAX) to FTP to that address and "see" your Remote machine?
  2. Does the file system on your Remote support a syntax for a path consistent with "\RT_Datafiles\tst.csv", i.e. no device or "root" designation?  I'm pretty sure, for example, that I couldn't use such as path to my PXI controller without the leading "c:".

Bob Schor

0 Kudos
Message 16 of 19
(1,927 Views)

Please my comments on the questions asked:

 

Is the IP of the Remote (which you have saved in the variable called "Host") 169.254.84.168?  Can you use Windows (or MAX) to FTP to that address and "see" your Remote machine?

Comment: Yes. I see and verify the cRIO IP in MAX. I can also ping the cRIO IP address successfully from the Windows cmd prompt window. 

 

Does the file system on your Remote support a syntax for a path consistent with "\RT_Datafiles\tst.csv", i.e. no device or "root" designation?  I'm pretty sure, for example, that I couldn't use such as path to my PXI controller without the leading "c:".

Comment: I am assuming the syntax for the path is supported becuase I did not get any error. In addition, I already tried "c:" and "C:" unfortunately that did not solve the problem either.

0 Kudos
Message 17 of 19
(1,916 Views)

OK, power is back on.  My Remote device (a PXI controller) did not have a file, Test.dat, on its C: drive.  I ran the following piece of code, which creates a temporary file on my PC, writes "File created " and the date and time, saves the file, then FTPs it to my PXI, saving it as c:\Test.dat.  Here is the code:

FTP Test.png

Here's the directory of my Remote (the file times are off -- I got confused by EDT vs UTC).  Notice Test.dat at the end.

Remote Directory.png

And if I double-click it, IE shows me its content:

FTP Contents.png

As advertised.  I'm not sure why something similar doesn't work for you.  

 

Bob Schor 

0 Kudos
Message 18 of 19
(1,905 Views)

Just a stab in the dark here...

 

Yre you sure the "\" is not supposed to be "/" on the remote target?

 

I know the file path controls handle this transparently, but Strings don't.

 

Also to make sure your paths are correct try reading a file from the target.  Once you have the paths sorted out, try writing.  That way there's a variable less in the test.

0 Kudos
Message 19 of 19
(1,884 Views)