LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch execution return value from System Exec VI

I am using System Exec VI to call an external program that programs a flash memory device. As System Exec is asynchronous, it initiates the programs, returns a 0 value and my LabView code proceeds to do the next step. However this external program is not done and I have to wait for it to finish. The external program has a return code but I don't know how to fetch it using System Exec. I want to implement a while loop that exits only after this program is done. How can I implement this ?

Thank you,
Sharmila
0 Kudos
Message 1 of 6
(3,368 Views)
The System Exec.vi has an input called "Wait Until Completion?". If you set this to True, then the System Exec.vi will not return until the program that it called has completed. You can then read any Return Code (from the terminal by that name) or if it would be outputting text, you can read that through the Standard Output terminal.

Rob
0 Kudos
Message 2 of 6
(3,361 Views)
Yes, that works. Nice.

Now here's what I want to do. I want to implement a timeout condition. So say the execution of external program has to complete within 1 min or else I have to force to stop it. How can I implement this ?

Thank you,
Sharmila
0 Kudos
Message 3 of 6
(3,357 Views)
I read a number of messages where it was mentioned that there is no way to timeout a System Exec when Wait Until Completion is True. If so, is there any other way I can call a executable?

I was wondering if this "much needed" feature will be implemented in future versions of Labview.

- sharmila
0 Kudos
Message 4 of 6
(3,349 Views)
Interesting problem. You can always ask the OS to kill off the process, which could get you where you need to go.

Attached is an example that uses a System Exec call to "killtask" and a notifier to control whether or not that command gets called. I used ping.exe as the sacrificial process since it's easy to keep it going for a user-specified period of time, so the example will only run properly on a machine with a network card. In practice, you can use any process and you could code something similar for Mac or Linux.

I avoided Quit Application.vi from the Windows Utilities suite because that only works if the window isn't minimized, and I suspect most programmatic System Exec calls will want to keep everything hidden.

Take care,
John
Message 5 of 6
(3,343 Views)
Hi John,

This works perfect! Thank you so much.

- Sharmila
0 Kudos
Message 6 of 6
(3,326 Views)