NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving pictures on Linux cRIO leveraging Linux tools/programs/etc.

Solved!
Go to solution

I have a project where I wish to save front panel control image to an image file (format doesn't matter). I am currently using a 9074 and the standard Windows method of export front panel image, save image data to file doesn't work. There are a few problems with this method, first the front panels don't working Real-Time like they do in Windows and secondly the code to save image data to disk probably calls something from Windows that isn't there in RT.

I will be switching to 9066 Linux based controllers and was wondering if there was a Linux program that I could call from the command line to handle the saving image data to disk? I have a 9033 to do some testing on, but I'm familiar with Linux enough to even get started.

Anyone have any ideas?

Doug

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 1 of 13
(6,480 Views)

Maybe I could save the pixmap array to disk then use some Linux command line program to import said pixmap array and convert to jpg, png,etc.?

I tried the unflatten image data to pixmap and the deployment dies. Hmmmmmm.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 2 of 13
(5,084 Views)

Doug,

On the 9033, are you enabling the embedded UI? If that's the case, I am not too surprised that the programmatic approach may not work. For that case, I'd recommend installing a package of commandline image tools called imagemagick. This will install the import commandline utility that can be used to grab a screenshot from the LabVIEW SystemExec.vi utility VI.

import -window root screenshot.jpg

Note that imagemagick is installed through the on-target opensource package manager opkg, not MAX (as it is not NI software).

From a terminal window on the target:

opkg update && opkg install imagemagick

0 Kudos
Message 3 of 13
(5,084 Views)

Note, also, that a 9066 won't have an embedded display (only the x86_64-based NI Linux RT targets have embedded displays, the 9066 is an ARM Zynq-based target)

Message 4 of 13
(5,084 Views)

Yeah, I know that the 9066 doesn't have a UI. Doesn't matter because our cRIO won't have UIs. I sort of stated that to clarfiy that the methods I had previously used for Windows environments don't work in Real-Time. First the UI isn't loaded and second it appears that the pixmap/save to jpeg VIs can't even run in Real-Time either.

However I think I have found a solution IF I can find and deploy gnuplot on our Linux RTOS.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 5 of 13
(5,084 Views)

OK, I got gnuplot to work the way I wanted in Fedora 23. I struggled mightily to get gnuplot on my cRIO 9033 manually. Seems the opkg has some rules that aren't overly obvious to a newb like myself. I finally gave the 9033 a dynamic IP and connect it to our company network and was able to opkg install gnuplot. I usually give all my cRIO static IPs because our end products are static and on a private network without Internet connection. Anyway I finally got gnuplot loaded and now I am going to test LabVIEW system exec calls to run gnuplot programmatically.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 6 of 13
(5,084 Views)

Ok, I did a test run of using the terminal on the 9033 to exectute my commands and they worked as expected and what I saw in Fedora. With the execption I got some font issue that ended up not effecting the output that I could tell. Here is what I typed...

putty.JPG

I then opned a new VI and tried to pass these commands into the System Exec VI as strings and nothing really happened. I assume there are a couple issues. First how does the System Exec log in a a user with permissions?

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 7 of 13
(5,084 Views)
Solution
Accepted by topic author DougFerguson

The SystemExec.vi utility doesn't take kindly to interactive commands like gnuplot's asking for. Such programs usually allow for you to put down the commands you want in a script file for the program to take as input, and gnuplot's no different, accepting additional arguments to the commandline invocation as files to be read in for commands to run non-interactively.

~/work/git/linux $ echo "show version" > gnuscript.txt

~/work/git/linux $ gnuplot gnuscript.txt

          G N U P L O T

          Version 5.0 patchlevel 2    last modified 2015-12-24

          Copyright (C) 1986-1993, 1998, 2004, 2007-2015

          Thomas Williams, Colin Kelley and many others

          gnuplot home:     http://www.gnuplot.info

          faq, bugs, etc:   type "help FAQ"

          immediate help:   type "help"  (plot window: hit 'h')

~/work/git/linux $

0 Kudos
Message 8 of 13
(5,084 Views)

OK, So I will search the gnuplot documentation for how to develop scripts and then using the system exec vi call that script?

Any help is apperciated as I literally have 2 days of exposure to Linux.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 9 of 13
(5,084 Views)
Solution
Accepted by topic author DougFerguson

Writing a script and calling with System Exec VI works like a champ!

Thanks!

My script looks like this...

# Gnuplot script file for plotting data in file "RI Plot.dat" to a png file

# This file is called Plot PNG.p

set datafile separator "\t"

set term png

set output "/home/lvuser/plot.png"

plot "/home/lvuser/RI Plot.dat" using 1:2

The system exec vi call looks like this

gnuplot "Plot PNG.p"

I have to set the working directory to "/home/lvuser"

Doug Ferguson

www.southerndaqsolutions.com
Message 10 of 13
(5,084 Views)