LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing STOUT/STDERR from C DLLs


wiebe@CARYA wrote:

But why do you still need that? If you run the .NET code, the dll's stdout will end up in the string... At least, that's the plan.


Maybe I'm not understanding then.  I don't see in your code where you're calling into a DLL that would call a printf.  I just see LabVIEW code that pushes text into a stream.  Let me look at it again and try it.

0 Kudos
Message 21 of 47
(1,654 Views)

My apologies.  I wasn't understanding.  I'm about to give it a try now.

0 Kudos
Message 22 of 47
(1,649 Views)

I wasn't able to use the snippet directly so I had to manually put it together, which required some searching for .NET methods - I've never used .NET before so I'm a little slow.

 

I'm not able to make it work if I've put it together correctly.  I'm going to keep playing with it.  I'm guessing maybe that the "Console" or "MemoryStream" methods are not really connecting me to STDOUT.  The code runs without error, and my dll call is returning normally, just no output is seen.  This is how I've implemented it:

 

(FYI, I'm highlighting code execution so the dll call loop is not running full speed - the read loop is able to execute repeatedly, it just returns nothing.)

StdOut Redirect_with_dll.png

 

0 Kudos
Message 23 of 47
(1,639 Views)

What errors\messages do you get when pasting the snippet?

 

Can you upload the dll?

 

Do you get a read when you run the other VI (Console.WriteLine)?

 

0 Kudos
Message 24 of 47
(1,635 Views)

The code snippets seem to be manipulated by uploading or downloading. My own snippet changed from 35 kB to 17 kB.

 

Here's the snippet as attachment.

Download All
0 Kudos
Message 25 of 47
(1,628 Views)

Attached is the dll and the source .cpp file.  There are a few other routines in there as I've been tinkering a bit.  The goal is to have the "printstuff" - which only has a printf and a return, work - without any of the redirect stuff in the other routines.

 

I haven't attempted the Console.WriteLine.  I expect it will work, but I'll give it a try just to be sure.

Download All
0 Kudos
Message 26 of 47
(1,621 Views)

The dll fails to load:

 

LabVIEW:  Failed to load dynamic library because of missing external symbols or dependencies, or because of an invalid file format.

0 Kudos
Message 27 of 47
(1,617 Views)

I really appreciate you putting in all this effort to help me with this.  If I haven't said thank you before - thank you.

 

I rebuilt, removing all of the other unused routines.  This should just contain a single printstuff routine.

Download All
0 Kudos
Message 28 of 47
(1,610 Views)

Also, Console.Write does work and produces output in the Read loop.

0 Kudos
Message 29 of 47
(1,602 Views)

wiebe@CARYA wrote:

The dll fails to load:

 

LabVIEW:  Failed to load dynamic library because of missing external symbols or dependencies, or because of an invalid file format.


You don't have the Visual C  Runtime redistributable files installed that correspond the the Visual Studio version that was used to create the DLL! And this actually listens very closely, if you happen to have Visual C runtime V 16.00.29023 installed but the DLL was compiled in Visual Studio with Visual C runtime updated to 16.00.30319 then you are likely getting such an error.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 30 of 47
(1,596 Views)