LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
hebi22

Access to console output

Status: New

Hi

 

It would be great, If LabView would allow access to the console. This could help in the following areas:

  1. Access to console output and maybe even input of called Libraries (dll, so ...)
  2. Access to console when invoking external programs such as command line tools (Unix like tools...)
  3. Ability to write labview applications for the console.

At the moment I'm working with a third party dll which outputs debug messages to the console, but using labview as development environment, I have no chance to see the messages which might be very important. It is like flying blind...

 

I hope to see this feature in a next generation of Labview

 

Herbert

7 Comments
AristosQueue (NI)
NI Employee (retired)

What API would you like to see? Access to the console is available to some limited degree with the "System Exec.vi" (found in the palettes). What additional functionality, specifically, are you looking for?

hebi22
Member

System Exec will take care of my number 2 item.

Number 1 refers to call library function node or similar.

Number 3 refers to a labview executable which can be used from the command line in general for example to pipe data in and out or to be used on a headless sytem (no gui)

 

For me most important at the moment is to have access to the console (stdout, stdin, stderr) when calling library functions in a DLL

 

I hope this clarfies...

myle00
Member

Well, this example VI lets you listen to stuff written to stderr and stdout from LabVIEW. I'm not sure if that was part of what you wanted.

 

Within a dll loaded by LabVIEW you have the following example code which when executed by LabVIEW shows up in the VI output.

extern "C"	__declspec(dllexport) void __stdcall STDerr(char * str)
{
	fprintf(stderr, "%s\n", str);
	fflush(stderr);
}

 I had to put in the \n because otherwise it never got to LabVIEW.

 

You can do the opposite for stdout (to write to stdout from LabVIEW so that it shows up in the dll), I imagine.

 

stdout.png

hebi22
Member

This looks like it can take care of my main problem. Can you post above vi somewhere so I can download it?

Thanks, Herbert

myle00
Member

The image is a LabVIEW code snippet (http://zone.ni.com/devzone/cda/tut/p/id/9330) so you can just drag it into your block diagram. But if you have a previous version of LabVIEW (than 2011) I'd have to upload the actual VI saved to a previous version. However, I couldn't find how to upload anything here (other than pics), so maybe if you post a question on the LabVIEW main forum I can post it as a response, or maybe I should just post it as a new thread?

 

In that case it' be more accessible and I could make the VIs a bit nicer and write the stdin example and show how to get the above VI out of the main loop if no one is writing to stderr because this VI will wait until something is written to stderr and not return before that.

 

Matt

myle00
Member
Rob_Calhoun
Member

Bumping this.

 

I was excited to see LabViewCLI introduced in LabView 2018, but it looks less interesting than I had hoped. Rather than giving us a way to write a console application using LabView, LabViewCLI seems to be a separate console application that talks to a single instance of LabView via the VI Server.

 

The limitation of using the VI Server is that only one application can listen on a given TCP port at time, so this does not provide a way to write generic console applications in LabView as one can with, well, pretty much any other programming language. That precludes use of LabView for many common coding tasks.  The release of LabViewCLI is a nice step in terms of acknowledging the need for programmatic builds from e.g. Jenkins but it doesn't address all of use cases for console applications.

 

Some other discussions on this topic:

https://forums.ni.com/t5/LabVIEW/Write-to-STDOUT-from-Labview-EXE-Ran-from-Console/td-p/3297020

https://lavag.org/topic/13486-printing-to-the-standard-output/

https://lavag.org/topic/20360-collecting-stdout-from-labview-when-run-from-jenkins/