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: 

Generate std out from Labview exe

Solved!
Go to solution

Hi folks,

 

From Labview, I know how to call an external program (with System Exec.vi) and read all the standard output that are done by this program and displayed in the Command Prompt window. That works well.

 

My question is: how to do things the other way around ?

If I start a Labview executable from another application, using a command line in the Windows Command Prompt, then how can I configure the Labview program to output information in the Command Prompt that was used to call the Labview application ?

 

I would like the Labview application to provide feedback to the calling application. I know there are other solutions like a log file for example, or even database (since I have a database available anyway). But right now I am interested only on std out in the console.

 

Thanks a lot for your help.

Best regards,

Luc

0 Kudos
Message 1 of 5
(2,000 Views)
Solution
Accepted by LucG
Message 2 of 5
(1,962 Views)

I'd personally compile a small .NET exe that reads a named queue and outputs it on the command line. The .NET has a build in compiler, so you won't need to install anything.

 

Then write to the named queue from LabVIEW (or another command line, C# program or whatever.

 

Optionally start LabVIEW with the name of the queue to use, and start the .NET exe with the name of the queue to use. For maximum flexibility. 

Message 3 of 5
(1,938 Views)

Thank you for your answers.

 

This post from notatamelion is very nice. I recommend it, at least as general knowledge for Labview developers. And in his post, Mike is also sharing the VIs he developed. That is really helpful. Thank you Mike.

 

There is one side effect to the current way things are programmed (and solutions can easily be programmed to solve the issue).

The separate application that is ran like a subVI, and is supposed to return data to the caller, will write data in the Command Prompt window, no matter if the prompt has already returned or is still waiting for the "sub-application" to end. See screenshots below.

 

For the sake of this example, I built an application that simply performs a count down and displays the values in the the prompt.

If you start the application using "cmd /c...", then everything works as planned. The prompt waits for the app to finish, and output from the application are displayed correctly.

 

LucG_0-1604041290621.png

 

But if you omit the "cmd /c..." then the prompt returns immediately, but the app will still write the output in the prompt window !

LucG_1-1604041341982.png

 

First of all, this is not a bug. It is more something that was not in the specifications. 😉

The purpose of Mike's blog post is to be able to return data from a secondary application to the caller, via the Prompt/Console. To do so, you have to use the "cmd /c". It makes sense. So everything works as planned. And Mike's post answers perfectly my needs.

 

And second, this can be solved easily by simply adding an extra input to the application to tell whether data has to be output in the prompt or not. This way, the application can be used in a more versatile way.

 

Thanks for the help.

Best regards,

Luc

0 Kudos
Message 4 of 5
(1,891 Views)

@LucG wrote:

First of all, this is not a bug. It is more something that was not in the specifications. 😉


It is in the specifications. Just not the specifications of LabVIEW, as it is not a LabVIEW specific switch... If you'[re going to use cmd for LabVIEW, you should look in the cmd specifications..

0 Kudos
Message 5 of 5
(1,886 Views)