08-03-2018 01:00 PM
Hi,
I I have an application where I call a python script within a while loop using the "System Exec.vi" that communicates with a piece of hardware. Each iteration of the loop feeds a different number to the standard input of "System Exec.vi" which is then passed on the hardware. The python script imports several modules which end up taking about half a second, and the rest of the script executes very quickly. When running the script from the terminal, the preamble executes once and the rest of the script (within a while loop of the python script) loops. When running it from Labview, the entire script executes within the while loop and then seems to close. This becomes a problem because I would like the Labview while loop to execute in ~500ms, which is the entire time that the import commands in the python script take to run. It does not seem that I can have a separate System_exec outside of the Labview while loop that just imports the modules, since this occurs in a different terminal and labview then opens a new session for the System_exec within the while loop. Is there any way around this? I essentially want a way that the terminal within the while loop stays open and I do not have to reimport the modules during every iteration. NI4.vi is what I would like to work, and NI3.vi is another option I tried that also does not work.
08-03-2018 03:59 PM
Just saying that LabVIEW 2018 has python functions. Not sure if it would make a difference.
(Sorry, I don't use Python, so no specific help)
08-03-2018 04:08 PM
You might try using .NET to make the call. It may give you more control over the process. Same as Altenbach, I have no experience doing this so I can't give you any help.
https://stackoverflow.com/questions/691716/running-cmd-commands-via-net
05-22-2019 08:25 AM
Did it work? I'm having the same problem.