|
|||||||||||||
11-08-2011 07:29 PM
Continuing from the comments in this idea: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Acce
For stderr and stdout, just run the "example output" VI and while that is running write to stdout or stderr from a dll loaded in LabVIEW like the following code or using the "STD write" VI and it'll show up in the "example output" VI's indicator.
extern "C" __declspec(dllexport) void __stdcall STDerr(char * str)
{
fprintf(stderr, "%s\n", str);
fflush(stderr);
}
Note, I had to add both a new line and fflush, otherwise it didn't consistently get to LabVIEW.
Now, for stdin I was having a bit of trouble. Doing the same thing (running the "example input" VI) resulted in a string control not being read in the loop. Just run the "example input" VI and while it's running change the "string to write" control to different text and you'll see that the new text will only be written after you press the stop button which doesn't make any sense.
The second issue I had was when I tried to read stdin from the dll loaded by LabVIEW. Even with trying AllocConsole() I always got EOF (e.g. when calling getchar(), see the code) independently of the VIs, it just seemed that stdin was disabled so I couldn't read from it, yet AllocConsole should have enabled it but it didn't. Also, printing to the console didn't actually display anything on the console. This may have something to do with this thread: http://forums.ni.com/t5/LabVIEW/using-stdin-stdout
Anyway, I if someone can get stding to work, I imagine they would be able to use the second set of VIs to write into stdin from LabVIEW and read it in the dll.
//AllocConsole();
FILE* f;
fopen_s(&f, "test stdin.txt", "w");
for (int i= 0;i<100;++i)
{
fprintf(f, "%d\n", getchar());
}
//FreeConsole();
fclose(f);
11-09-2011 04:09 PM
Hello myle,
I ran the VI's it seems that it's writing and reading, I used the example input. I don't know exactly what it is that you want to fix on this VIs, if you give me more information I can work on it.
Regards,
11-09-2011 04:57 PM
ie.aleja wrote:
Hello myle,
I ran the VI's it seems that it's writing and reading, I used the example input. I don't know exactly what it is that you want to fix on this VIs, if you give me more information I can work on it.
Regards,
You can write off the first issue as user error
I updated the string control to new text, but I never clicked out of the string control until I clicked the stop button so the new string only got read when I hit the stop button
I didn't realize/forgot that the string control only updates to the new text once you click out of it. So it does work as expected.
Thanks.
03-06-2012 06:49 AM
Please, can you post the files saved for Labview 8.2? Thank you.
03-06-2012 07:53 AM
There is a property associated with string controls called "Update While Typing", accessible via right-click menu or as a property node. I think it's typically used with event structures, but if you need that kind of functionality, it might be useful to set in your program too.
http://zone.ni.com/reference/en-XX/help/371361H-01
http://zone.ni.com/reference/en-XX/help/371361H-01
03-07-2012 12:17 PM
If you want files converted to LabVIEW 8.2, you can visit the Version Conversion discussion forum to request someone to convert the files for you:
http://forums.ni.com/t5/Version-Conversion/bd-p/Ve
04-17-2013 01:54 PM
I tried this method in Labview 2012. However the fflush() is causing labview to crash!
I can't seem to get any output without the flush either.
My Profile | Privacy |
Legal |
Contact NI
© 2011 National Instruments Corporation. All rights reserved. | E-Mail this Page
|
||

E-Mail this Page