SFTP File Transfer for LabVIEW

Please note that this project is no longer being supported and does not support some of the newer connection methods.

Leading on from the LabSSH Library that I shared a while back, I have also created a LabSFTP LabVIEW library.

From Wikipedia, SFTP can be described as follows:

In computing, the SSH File Transfer Protocol (also Secure File Transfer Protocol, or SFTP) is a network protocol that provides file access, file transfer, and file management over any reliable data stream.

As with LabSSH, LabSFTP uses a custom .net class that incorporates some of the features of the RENCI SSH library.

LabSFTP offers the following features:

  • Password authentication to a remote host
  • Private/Public key authentication using the openssh key format
  • The ability to get a list of files or folders from a specified location on a remote host
  • The ability to upload files
  • The ability to download files
  • A public method to check the connection status
  • A public method that will send a stay-awake signal at a specified interval

The video below shows the library being used in an application. The LabVIEW application is communicating with a LinuxLite installation running on a virtual machine.

To get up and running, open the library and start by running the test vi. This will create a connection, get a list of files from a specified location, upload a file and download a file. Make sure that your paths are correct. It has been left to the developer to make sure that files and paths are correct before executing the the specific methods.

As with all my posts, you can download the LabVIEW code below. If you have any feedback, please feel free to contact me on Google+ or send me an email. The LabVIEW application has been tested using LinuxLite and on the latest Raspbian Jessie image running on a Raspberry Pi3.

Download LabVIEW LabSSH & LabSFTP Library

Greg

LabVIEW User Groups

This week I attended my local LabVIEW User Group (CSLUG). I have been a member for a few years and can’t emphasise enough how much you can get out of a two (sometimes three/four) hour discussion once a quarter.

Topics that are discussed can be anything from new and advanced ideas, different ways of documenting code, error handling and anything else that you have an interest in or need help understanding. I am lucky enough to be part of a LabVIEW User Group that has three LabVIEW Champions and a very long list of LabVIEW Architects and Developers who are more than happy to share their knowledge and experience with those willing to learn.

Here are a few reasons to join a LabVIEW User Group in your area, and if there isn’t one, maybe get hold of NI and start one.

  • Meeting new developers in your area with common interests
  • Learning from people who work on bigger/smaller/different types of projects
  • Getting some advice before starting a project
  • Teaching others if you have done something interesting/different, no matter how big or small
  • Seeing how other people solve problems and write code
  • Being part of a community where you can help others and get assistance when needed is invaluable
  • If you don’t have experience presenting in front of an audience, this is a great place to learn 

What I got out of CSLUG this week:

  • A good idea on how to do error handling. Thanks to Steve Watts and James McNally
  • A very cool way to display chart data. Thanks James Powell
  • Creating scalable buttons using vector graphics. Thanks again to Steve
  • A brief introduction to Database Triggers. This is something I never knew about but will definietly be looking in to. Thanks to John White

The biggest idea I got from this weeks LabVIEW User Group was from a chat once most people had gone home. Late on the night before CSLUG I was working on a calibration process and was wondering how to get a value from the previous three states in a while loop. It was late, the code was working but could have been better so I left it for the night.

Then after CSLUG, someone mentioned something about multiple shift registers and something just clicked. I went home and immediately wrote a simple vi to test what I thought he meant and it was exactly what I was looking for.

The idea is that adding a shift register to a while loop gives you access to the value of the previous state. This I always knew and use often. What I didn’t know is that you can add multiple input terminals to a single output terminal. This means that the top input terminal is the data from the previous state, the terminal below is the data from the state before the previous state and so forth.

Labvolution - CSLUG

Here is a video of it in action.

Without attending the User Group I might never have come across this. It also wasn’t something on the agenda so you never know what you are going to learn, but you can be assured that you will learn something. Another invaluable tool I use (learnt from a LabVIEW User Group) is the vi property that suspends a vi when called. Have a look this blog post by Chris Roebuck, it will change the way you debug.

My hope for the new year is to try and get to some other LabVIEW User Groups in the area, to meet new people, learn something new and hopefully teach someone else something new.

Have a great Christmas, New Year and happy coding.

Greg

LabVIEW: Discovering New and Old Functions

I have been using LabVIEW Quick Drop for the last few years and find it really useful. I almost never open the functions palette anymore. The one problem I find with Quick Drop (not really a problem with Quick Drop) is that I end up using the same functions over and over again, without discovering new, different or more efficient methods of doing things. By opening the functions palette every now and then, you can quite quickly and easily notice new or unused functions.

This happened to me a few months ago when I stumbled upon the In Range and Coerce function.

LabVIEW In Range and Coerce Comparison pallette

With writing a lot of test software, I am always comparing measured values to target values. When there is an upper and lower limit, I used to use greater than, AND and less than function. This works but I always thought it looked a bit clumsy.

LabVIEW In Greater AND Less than target

Using Quick Drop, and what I thought to be a good search term to find the function that does this in one step proved unsuccessful.

LabVIEW Quick Drop greater and less

Then one day I decided to go looking through the Comparison functions palette and came across the In Range and Coerce function. This did everything I needed and more and I have used it ever since.

LabVIEW Quick Drop In Range and Coerce block diagram

Knowing what the function does and how it works, it’s obvious why it has the name that it does. This does however make it a bit tricky to look for functions without knowing the name of something and just knowing what you want it to do. Sometimes you find what you need and others you don’t.

LabVIEW Quick Drop In Range and Coerce

With the In Range and Coerce function, you can also very easily include or exclude the limits from the comparison.

LabVIEW Quick Drop In Range and Coerce block diagram include limits

I think Quick Drop is brilliant and significantly increases productivity; however I also think it’s a good idea to every now and then just browse through the functions palette to see the many, sometimes unused functions that are available.

LabVIEW Functions palette

Happy programming and enjoy looking for and using those sometimes unused, new or forgotten functions.

Greg

Installing VMware Tools for openSUSE

This is going to be a really quick post about getting VMware tools running using openSUSE. As mentioned previously, I am using virtual machines quite a bit lately and I had a need to install LabVIEW for Linux. I have used Linux a bit, but ran into all sorts of issues. The aim of this blog post is to help anyone out who has the same problem and also serve as a reminder to me when I need to go through the process again.

Installing openSUSE was straight forward, just follow the defaults. The only change I had to make was disk size and memory allocation in the VMware settings.

Once installed, the first stumbling block was to install VMware tools. This is not as straight forward as you would think. There are a few dependencies that are needed and these must be installed manually. These include GCC, make and the kernel header files. This is not made clear while installing VMware Tools.

Open a terminal and run uname -r and uname -m. This will print the kernel name and machine name.

Linux LabVIEW VMware - kernel

Next, open Settings > YaST > Software Management. Search for ‘kernel-source’ and then under the Versions tab, select the version that was listed in the above step. In my case, I selected 3.16.6-2.

Linux LabVIEW VMware - kernel version

Repeat this step for ‘kernel-desktop’ and ‘kernel-desktop-devel’

Next install ‘GCC’ and ‘make’ using the YaST as explained above. Once everything is installed, reboot.

Linux LabVIEW VMware - gcc

Linux LabVIEW VMware - make

Open a terminal and execute the following command. ls /usr/src/linux-3.16.6-2-obj/x86_64/desktop/include/generated/uapi/linux/

This will show the location of the kernel header that VMware Tools will look for.

Linux LabVIEW VMware - kernel source headers

Make the directory where VMware will look for for the kernel header.  mkdir -p /lib/modules/<uname -r>/build/include/linux and copy version.h from the above step into this directory. You can also create a symbolic link, but I have not tested this.

Now extract the tar file from VMware Tools disk that is mounted and run  sudo ./vmware-install.pl. Follow the prompts and it should install OK. Reboot and everything should not work.

Linux LabVIEW VMware - Install complete

While the virtual machine is power off, enable a shared folder. This will be automatically mounted when the OS boots.

Linux VMware Tools - Shared folder

Boot the virtual machine and open a terminal. If everything is set up correctly, you will notice that the shared folder has already been mounted. ls /mnt/hgfs/Shared\ Folder/openSUSE/ will show your shared folder. You will need to change the names depending on your set up.

I have created a symbolic link (short cut) in my Documents folder to the mount directory. This is not needed, but I find it cleaner.

Linux VMware Tools - Shared folder sym link -s

Linux VMware Tools - Shared folder sym link

The next step is to get LabVIEW for Linux installed. That shouldn’t be too much of an issue, I hope!

Greg

Clone Live Windows Disk To USB

I have been using a Dell XPS 13.3 for the last few months and am loving it. It’s portable, light, got an amazing FHD screen with almost zero bezel and fast. Until recently it has been perfect, however I have started using virtual machines for work projects so the 256GB SSD quickly started to take strain. I thought I’d just get a larger SSD, make a clone and will be up and running in no time. I was wrong, very wrong!

I went for a Samsung 500GB M.2 SSD and because my XPS only has one SSD socket, I bought a M.2 SATA to USB 3.0 enclosure too. That was the easy part done. The ‘fun’ was only just beginning.

When looking at the original SSD in Windows Disk Management , you will notice that there are a few hidden partitions where Dell keeps OEM data, recovery partitions and the main C:/. I needed to clone all the partitions over to the new SSD which was connected via USB 3.0.

Clone Windows SSD to External USB - original ssd

I will start with the program that I ended up using, and then mention a few that I didn’t and why they didn’t work for me. This is not a step-by-step guide, as I am already working on my new SSD. It’s more for information and choosing a program to use.

Macrium Reflect

I came across Macrium Reflect by chance and I am so glad that I did. It was by far the easiest to get working.

Clone Windows SSD to External USB - Marcrium Reflect

All you need to do to get going, is install the software, I included Windows PE support for drivers in case they were needed. Connect your new SSD to a USB port. If the SSD is brand new and never been plugged in before, you will need to initialise the SSD using Windows Disk Management. Once the SSD is initialised and has a drive letter assigned to it, you are good to go.

Once Macrium Reflect is installed and your new SSD is plugged in, run the software which will look like this.

Clone Windows SSD to External USB - Marcrium Reflect main window

I made sure all other applications were closed and once ready, selected ‘Clone this disk…’.

The source disk will be the disk currently running and the destination disk will be the new disk connected via USB. Follow the prompts selecting the options that suit your installation and then run the clone. The clone I did on a 256GB SSD took around 1 hour to complete. After each partition is complete, a Windows Explorer window will open showing the newly cloned partition.

Once the clone is complete, shut down Windows, replace the SSD in your laptop with the newly clones SSD connected via USB and boot your laptop. My first boot took a few seconds longer than normal, but everything started perfectly.

Because my new SSD was double the size of the old SSD, there was an uninitialised partition at the end of the SSD. Using Windows Disk Management I initialised and assigned a drive letter to that partition and now I have loads of extra space to use.

Clone Windows SSD to External USB - Windows Disk Management

Programs that did not work for me

I am going to quickly cover the programs that did not work for me.

First I tried DriveImage XML as a many articles that I read suggested this application. The main reason I decided not to use this was you are only able to clone a single partition. I’m sure this works well when you have done the initial installation yourself into a single partition, but most PC’s/Laptops’s come with OEM installed Windows which includes multiple partitions.

I then tried EaseUS Partition Master as it was also a free application. This required making a Linux boot disk which you boot off and then you select which is your source and destination disk. Unfortunately when I booted off the boot disk, the SSD connected via USB was not recognised.

Thirdly I tried Acronis True Image 2015 which I bought a licence for as disk cloning is not supported in the trial version. Acronis True Image also uses a Linux boot disk to clone from one disk to another. When I first tried it, I had the same problem as EaseUS Partition Master where my the SSD connected via USB was not recognised. After installing the multiple media packs and spending hours on forums, I decided to look for another application as the workarounds mentioned seemed totally unreasonable for a paid, licensed application.

Conclusion and Solution

After many hours and multiple reboots, I finally found Macrium Reflect which worked first time, perfectly. From download to rebooting on my new SSD took less than 90 minutes, and I didn’t have to worry about making Linux USB boot disks. I highly recommend this program for performing clones on Windows disks. I am going to look at using it for my file and systems backups too. They also offer a free version that is loaded with features for non-commercial use.

As usual if you have any questions or comments, feel free to get in touch via Google+ or email.

Greg