LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

updating the value from call library function

Solved!
Go to solution

Hi everyone,

I am facing a problem configuring a CLF in Labview 2015-64.

I have a dll which is written in C++ (code is available) and need to be called in Labview for indication purposes. The dll should be called once and I need to keep reading the result as it is being updated.

 

Hier is a sample code in C++, and the goal is to read the sum pointer in LV as it is being updated in dll: (correct me please if the C++ code should be changed!). dll is also here attached.

__declspec(dllexport) void test_sum(int iteration, int waitTime, int *sum)
{
	for (int i = 0; i < iteration; i++) {
		*sum = i + 1;
		Sleep(waitTime); //wait in ms
	}
}

Here is the LV code I have made, it does not crash but just gives me only the last value (here 20). But I expect to copy the memory from the pointer every 2ms in the while loop and showing me the values from 0 to 20! 

dll_Call.JPG

 

 

Any help or hint is greatly appreciated.

 

 

0 Kudos
Message 1 of 4
(2,498 Views)

Why is the size 8? An I\U32 is 4 bytes?

 

You might try not running the dll in the user interface thread. It might block the UI thread regardless the Sleep.

0 Kudos
Message 2 of 4
(2,491 Views)
Solution
Accepted by Skydive

wiebe@CARYA wrote:

 

You might try not running the dll in the user interface thread. It might block the UI thread regardless the Sleep.


You can leave the "might" away. Make it:

 

You MUST NOT running the dll in the user interface thread. It WILL block the UI thread regardless the Sleep.

 

Rolf Kalbermatter
My Blog
Message 3 of 4
(2,473 Views)

Hi Rolf and wiebe,

 

thank you for the quick response. That was totally correct.

I had this problem before but apparently lessons not learned 😞

Hopefully everything will work when I change it to U8-2D array.

 

Thanks again.

0 Kudos
Message 4 of 4
(2,446 Views)