12-06-2020 04:38 AM
Hello All,
I need to run an external program in order to begin a certain test,
What is the best practice for running the system exec, bearing in mind that I want to kill the task after a certain time out.
I have tried using sequence structure, but the labview will not advance to the next frame unless the program is closed manually,
I want to use the kill task and close the external program after a certain time out.
Thanks!
Gil,
Solved! Go to Solution.
12-06-2020 10:30 AM
Does the program return data that you care about (i.e. via StdOut?).
If you set the CMD execution to be non-blocking, you can kill it using something like "taskkill", but you'd also need the Process ID using something like "tasklist".
However, setting the SysExec node to be non-blocking prevents it returning the StdOut output.
If you want to keep that, but allow cancelling the task (and you don't have some other method to cancel the task) you'd have to asynchronously launch a VI in LabVIEW to call the SysExec node, and then separately kill the task (as above) if the VI doesn't return before some timeout value.
By "some other method", I mean if the task you're calling allows interruption via something like TCP server, WCF messaging, etc.
12-07-2020 02:46 AM
Hi,
Thanks for you reply.
I understood the second part about using an asychronous VI to kill the task.
Can you please help me understand the first part of you answer, mostly:
"setting the SysExec node to be non-blocking prevents it returning the StdOut output."
Thanks!
Gil,
12-07-2020 02:54 AM
Sure - there's an input on the top of the SysExec node that's labelled "wait until completion? (T)".
If you wire a false value to that, then the node returns immediately, which would allow you to then continue execution in the same VI, and optionally do other things (like kill the task) some time later.
However, you lose information about when the task finishes - which makes it harder to use in your situation (I suspect).
The detailed help page has the following explanation:
If wait until completion? is TRUE, standard input is available as input to the command and standard output and standard error are available when the command finishes running. If FALSE, the command runs in the background and its input and output are not available.
12-07-2020 03:31 AM
Ok your reply, is much appreciated! I will not lose any data since the other application only creates a file which I can read later in my vi.
Thanks!
Gil,