I have a cRIO on a remote field, and I need that the program running on that platform periodically uploaded, through the internet, the data files to an FTP server.
I have used the FTP VIs included in the Internet Toolkit to develop this functionality and I am experiencing some problems.
During the uploading of files of medium or large size, via FTP, can happen that the FTP server closes the connection.
The reasons can be different, network operation exceeded the user-specified or system time limit, bandwidth usage is restricted or the bandwidth is limited, etc..
To overcome this issue the correct strategy is to reopen the FTP connection and to restart the upload from the point where it was interrupted.
It is very important to finish to upload only the remaining part of the file, and not to restart from the beginning, otherwise you could not end the upload if the FTP server closes the connection again and again.
For implementing the resume, the FTP protocol supports a number of commands:
SIZE <remote file-name> Returns the size of a file (Binary mode) .
REST <file-size> Sets the following STOR command to restart transfer
from the specified point.
STOR <remote file-name> If anticipated from a REST command, store (upload)
only the part of the file starting from the
At the present, it seams to me that the LabVIEW Internet Toolkit does not support the capability of FTP resume.
Furthermore, if during a FTP upload the connection is closed by the FTP server, the FTP [STOR].vi exits sometime with ambiguous errors.
Exit with a correct error:
Error 56 occurred at TCP Read in NI_InternetTK_Common_VIs.lvlib:TCP Read xTP Reply.vi:2->NI_InternetTK_FTP_VIs.lvlib:FTP Get Command Reply.vi:1->NI_InternetTK_FTP_VIs.lvlib:FTP Data Send.vi->NI_InternetTK_FTP_VIs.lvlib:FTP [STOR].vi
LabVIEW: The network operation exceeded the user-specified or system time limit.
Exit with an ambiguous error:
Error 54 occurred at TCP Open Connection in NI_InternetTK_FTP_VIs.lvlib:FTP Open Data Connection.vi->NI_InternetTK_FTP_VIs.lvlib:FTP Data Send.vi->NI_InternetTK_FTP_VIs.lvlib:FTP [STOR].vi
LabVIEW: The network address is ill-formed. Make sure the address is in a valid format. For TCP/IP, the address can be either a machine name or an IP address in the form xxx.xxx.xxx.xxx. If this error occurs when specifying a machine name, make sure the machine name is valid. Try to ping the machine name. Check that you have a DNS server properly configured.
Do you have idea or suggestion of how realize an FTP STOR command with REST capability?
before to post I did several unsuccessful searches in the all NI site.
As I have stated at the beginning, I'm developing the code on a cRIO, i.e. a real-time operating system, calling a FTP client is not a solution.
More ideas or suggestions,
Unfortunately the best advice I could give you would be to make a copy of the FTP toolkit and add this functionality yourself. You should have most of the building blocks available to you so it should be fairly starightforward. You could reference the RFC (RFC 959 and RFC 3659 for extensions) for any specifics you need on the packet format. You will need to save some state information so you can resume your download from the correct point.
Would it be possible to use TFTP? This is much leaner and more likely to succeed if the other ends supports it. I recently wrote a very basic TFTP Write. I'm sure I could do the TFTP Read in short order. I'm still working on packaging it up in a distributable form but I could provide you with a basic VI if needed.
I was looking at the FTP code and it is pretty big. If you don't need multiple sessions and all of whatever else is in there it might be easier to just roll your own. And as Mark said you need to keep track of state somewhere.
thanks for the advise, unfortunately the TFTP is not the solution because both it provides no authentication and it is rarely used by internet service providers.
Could you send the file over the network from the crio to another system and do the FTP from there? Maybe then you could do the system call to an FTP client. May or may not work in your situation - just throwing out suggestions.