From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to 'timeout' the 'System Exec.vi'?

When I run the 'System Exec.vi' I can't set any timeout option. When I run the 'System Exec.vi' I'm reading until it terminates and I can read out the ouput status. This isn't a good solution because my DOS-app could hang up and the 'System Exec.vi' is running endless (I set the 'wait until finish' option)!

Unfortunately I can't read the status output continously (this would be the best way!) because the DOS-app is blocked through the LV. I also tried to redirect the batch file output (the batch file starts my DOS-app)to a txt-File. This solution isn't working because the txt-File is not updating due the LV and/or DOS-app is running, although I closed the file after I read it out in my LV-app!

I could 'solve' the problem when I wait until the 'System Exec.vi' terminates (which works) but I do need a timeout in the 'System Exec.vi' so that I can interrupt if my DOS-app hangs.
There is another 'Exec+.vi' on the net but unfortunately this has no status output - but instead a timeout function! ;(


Is there any other solution?

Thanks
Norick
0 Kudos
Message 1 of 6
(4,825 Views)

Hi Norick,

  I'm having a little trouble understanding exactly what you need, but maybe this will help.  Could you run your program in 3 steps using a sequence structure with three frames?

1) get the current milliseconds by using Tick count.  Pass this value to the next frame using a sequence local

2) run your system exec command using "wait until completion" to false and having your command line create a dummy file when it finishes

3) keep checking the milliseconds by again using tick count and comparing to the value in frame 1.  If too many milliseconds have passed, or you find the dummy file, move on, if not, keep checking.  You could use a while loop here.

  Again, I'm not sure about what you need in the way of output, so this may not work, but just an idea.  Good luck,

PP

0 Kudos
Message 2 of 6
(4,789 Views)
Hi PP
well this would work but it's not exactly what I need. Here again the problem with the SystemExec.vi:

1) I have a DOS app which I run through the SystemExec.vi
2) This DOS app creates at the end a Status output which I need to read in with LV to check the result (Pass/Fail)
3) Unfortunately I can only read AFTER the DOS app finished!
4) Question: How can I read this status output coninously in LV to check the result from my DOS app??


Norick

0 Kudos
Message 3 of 6
(4,771 Views)

Norick,

  Does your DOS app, if run from the command line, produce output WHILE it is running?  If it does, try changing the input to system exec in command line to something like "myprogram.exe > output.txt".  Doing so will pipe all output normally put to the screen to a file just like the file were the screen.  You can then read that file nearly continously, with a small break in between.  I've created a simple example and have attached it.  You may need to play with the active directory input to get he output file where you want it.

  If your program only outputs data to the screen when it is finished, then there is nothing LabView can do.  You will need to play with the DOS App to get the data outputed during execution.  Does this help?

Good luck,

PP

Message 4 of 6
(4,758 Views)
Oops, forgot attachment
Message 5 of 6
(4,753 Views)
Yeah my DOS app gives me contin. a status back while it's running. So this is a very good idea to generate a .txt file which I can read in
with LV!
I will try it out and check how it works.

Thanks for your help... best regards

                   Norick

0 Kudos
Message 6 of 6
(4,732 Views)