NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
clnorris
Posts: 23
0 Kudos

using stdin/stdout with LabVIEW

When I'm debugging a C++ DLL, I use AllocConsole() to open a console for the calling process, redirect stdout with freopen(), then I use printf() generously.  This also works when I load my DLL in LabVIEW.  I was curious if stdin, stdout, and stderr point anywhere by default in LabVIEW.  Can I access these streams in some way from LabVIEW without redirecting?  If anyone has experimented with this, let me know!
 
Thx!!
 
Active Participant
Wiebe@CARYA
Posts: 1,324
0 Kudos

Re: using stdin/stdout with LabVIEW

Hi,


I did some experimenting with the AllocConsole(), but I don't think much useful can be done with it..


You can use AllocConsole, and WriteFile, etc. to output strings to a new console. But I never succeeded in outputting LabVIEW data to it's command line. I even tried the redirect piping example from the MSDN, but it didn't work. Normal windows applications just aren't supposed to do this.


I think CGI works by outputting data to the command line, and I think CGI is included in the internet connectivity toolkit. So perhaps by abusing the CGI you can use the stdin, stdout.


What would you like to achieve?


Regards,


Wiebe.



"clnorris" <x@no.email> wrote in message news:1146872408717-361573@exchange.ni.com...
When I'm debugging a C++ DLL, I use AllocConsole() to open a console for the calling process, redirect stdout with freopen(), then I use printf() generously.&nbsp; This&nbsp;also works when I load my DLL in LabVIEW.&nbsp; I was&nbsp;curious if stdin, stdout, and stderr point anywhere by default in LabVIEW.&nbsp; Can I access these streams in some way from LabVIEW without redirecting?&nbsp; If anyone has experimented with this, let me know!
&nbsp;
Thx!!
&nbsp;
Member
clnorris
Posts: 23
0 Kudos

Re: using stdin/stdout with LabVIEW

I'm using a console to display printf() output from a DLL that I'm debugging when it's loaded in LabVIEW.  This works great.  I wanted to see if the streams are going somewhere useful by default in LabVIEW or at the very least confirm that redirecting stdin/stdout won't mess anything up in LabVIEW's process.

Thanks for the feedback!

Trusted Enthusiast
rolfk
Posts: 4,056
0 Kudos

Re: using stdin/stdout with LabVIEW

[ Edited ]


clnorris wrote:

I'm using a console to display printf() output from a DLL that I'm debugging when it's loaded in LabVIEW.  This works great.  I wanted to see if the streams are going somewhere useful by default in LabVIEW or at the very least confirm that redirecting stdin/stdout won't mess anything up in LabVIEW's process.

Thanks for the feedback!



Windows dinstinguishes between two basic types of applications (Just leave out Active X and .Net for the moment). One is a console application and the other is a GUI application. GUI applications by default do NOT have any stdin/stdout and as far as I know does LabVIEW not do anything to change this. In order to have some sort of stdin/stdout functionality in a GUI application you have to explicitedly allocate a console and associate some streams with its stdin/stdout in order to have printf and friends do something meaningful. I believe that printf and friends otherwise just are redirected to NUL.

Rolf Kalbermatter

Message Edited by rolfk on 05-12-2006 11:41 AM

Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

LabVIEW Champion
Member
owillebo
Posts: 12
0 Kudos

Re: using stdin/stdout with LabVIEW

Windows knows two types of apps; gui or console.

This is controled by a bit in the binary.

If the app is console windows creates a console and opens streams when starting the app.

MS has a tool, named editbin, that can toggle this bit.

  • EditBin MyProgram.exe /SUBSYSTEM:CONSOLE
  • EditBin MyProgram.exe /SUBSYSTEM:WINDOWS

Make the LabVIEW app console and all printf's or couts appear in the console.


editbin is delivered with visual studio. perhaps there are other sources to. it needs the visual studio linker.

It can also be used to set other nice stuff in binaries.


Okko Willeboordse

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page