Hi Mark,
If you did need a libcurl library for windows there is one that uses the EPICS build system at
https://github.com/ISISComputingGroup/EPICS-curl by default it will expect the OpenSSL built from
https://github.com/ISISComputingGroup/EPICS-OpenSSL but can probably use one downloaded from elsewhere too
Regards,
Freddie
From: Tech-talk <[email protected]>
On Behalf Of Mark Rivers via Tech-talk
Sent: 14 November 2019 14:39
To: [email protected]
Subject: Uploading a file with SFTP from an EPICS driver
Folks,
I am working on the driver for the Newport XPS motor controllers. These controllers can execute Position-Velocity-Time (PVT) trajectory scans which are complex multi-axis coordinated motion along a user-defined path
in 8-space. The trajectory is defined in a text file, which the EPICS driver creates and then uploads to the controller. The older XPS-C8 and XPS-Q8 controllers support FTP for the upload. I have a small C implementation of FTP which the driver uses. This
C code is standalone, it only needs to call the standard socket functions.
The new XPS-D8 controller does not support FTP, it only supports SFTP/SCP. I need a solution to be able to do SFTP transfers from within my C++ EPICS driver. I want the solution to work on both Linux and Windows, and
ideally on vxWorks as well.
I have tried 3 solutions, and measured the time that each solution required to upload a 5KB file. The results surprised me, and I am curious if anyone can explain them.
The code for the 3 solutions is in the attached xpsSFTPUpload.cpp and the test program is testSFTPUpload.cpp.
Solution 1. Use libssh2. This is selected if CONFIG_SITE defines HAVE_LIBSSH2=YES.
Execution time = 326 ms
Solution 2. Use libcurl with the curl_easy API. This is selected if CONFIG_SITE defines HAVE_LIBCURL=YES.
Execution time = 323 ms
Solution 3. Run the “curl” program with the C system() call. The driver builds the text of the curl command and runs it with the system() call. This is selected if CONFIG_SITE does not define HAVE_LIBSSH2=YES or HAVE_LIBCURL=YES.
Execution time (Linux) = 126 ms
Execution time (Windows) = 270 ms
So on Linux running the “curl” command via a call to system() is actually almost 3 times faster than calling either of the libraries directly. This surprises me.
Note that I actually prefer to use Solution 3 because it is easy to implement on Windows. There are several sites that provide downloads of a pre-built “curl” executable. However, I have not been able to find any site
that provides the libssh2 or libcurl libraries in a form that can be called from Visual Studio. They are built with mingw and give errors when I try to link with Visual Studio. Note that because of the performance measurements above I am not motivated to
pursue the library solution either, since it seems to be significantly slower.
Ideally I would like this driver to work on vxWorks as well, but I don’t see any solution for doing sftp from within a C program on vxWorks?
Thanks,
Mark