LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System exec Vi cannot call external code

Hello,

I used the System Exec vi to call a MATLAB executable I created. The Matlab code asks for inputs, so in my VI I specify the path to the exe and then put the desired commands through the standard input. The matlab executable works, and the vi itself works also.I can use it separately. but whenever I incorporate it into the rest of my project it fails. It is intended to sit inside an event structure and execute after a button press. There is a while loop around the whole thing as well.

When I run the exe alone or call it from my vi, the cmd prompt shows up and then the plots which is created in the matlab code,. In the case when the vi is inside this event structure and while loop, the cmd prompt shows up for a short time and then disappears.

The "wait til completion" option has to be set to true, because otherwise I get the cmd prompt but my commands do not get passed on.

Anybody have an idea about what might be happening in my case?
0 Kudos
Message 1 of 4
(3,186 Views)

If I understand correctly, the VI which has the Event Structure continues to execute and does not wait until Matlab is done, right?

You would need to monitor the state of the executable to see if it is still running.  When the executable completes, does it return a value, like 0 to say all was fine, or -1 for an error?  If so, then you could set it to wait for the response for your VI (with the Event Structure) to continue. Or implement something similar, but you would need to trigger on the executable being done..

RayR 



Message Edited by JoeLabView on 07-01-2008 11:19 AM
0 Kudos
Message 2 of 4
(3,182 Views)
The vi with the event structure waits for the exe to finish, but the actual execution of the exe is cancelled for some reason. The standard output says an error occured within the exe, yet when I run the same VI separately it works fine. It seems like the problem would be in the .exe, but I checked and it is fine. the next point of failure would be the interface between the Sys Exec and the cmd - perhaps my inputs are not passed on.

I was wondering if the while loop and event structure have a known issue with the type of input I am trying to use?
Thank you for your help,

Alek
0 Kudos
Message 3 of 4
(3,170 Views)

I'm not aware of any problems when using the Event Structure.

Try wiring indicators to the output of the Sys Exec.  For "return code", "standard output" & "standard error".  It is probably an error due to how the parameters are passed to the executable when using the Sys Exec.

You do place the parameters inside quotes, right?  You can also try placing the command string into Sys Exec's "command line" input, and the parameter string into the "standard input".

RayR



Message Edited by JoeLabView on 07-01-2008 02:21 PM
0 Kudos
Message 4 of 4
(3,142 Views)