LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a pointer parameter for DLL

Solved!
Go to solution

Most often this error is due to choosing the wrong calling convention in the configure call library dialog. Are you using WINAPI or C? Most likely you should be using C. Also try setting the error checking level to Maximum and see if you get a more helpful error message.

0 Kudos
Message 11 of 18
(1,452 Views)

It looks like changing [calling convention] to stdcall (WINAPI), I no longer get error when I run the code.  However, I am still not sure if I am getting back anything valid from the DLL.  I used a "getvaluebypointer.xnode" as recommended in previous thread, I assume the DLL is suppose to give me a value that points to the memory location of the 3 bytes for (1, I2C freq, 2, 3.3V power output state, 3, 5V power output state).  The return type is defined as int 32.

 

untitled.JPG

0 Kudos
Message 12 of 18
(1,441 Views)

You were misled in the first reply. If the function calls works properly, your data is in the array output (directly across from the array input). The return value is something else entirely, probably a success/error indicator but you'd have to check the documentation.

 

Why are you initializing the array to 255 elements? From the documentation, it appears that you only need 3 elements (for the three values).

0 Kudos
Message 13 of 18
(1,436 Views)

I have tried an array size of three, it doe not make difference.  I get back a zero from the DLL.

0 Kudos
Message 14 of 18
(1,431 Views)

Can you post your code?

 

Also, are you sure 0 is the wrong value? Try initializing the array to something else before you call the function and see if it still returns 0.

0 Kudos
Message 15 of 18
(1,426 Views)

@ZhuoCao wrote:

I have tried an array size of three, it doe not make difference.  I get back a zero from the DLL.


A zero return value? That may be an error code return and 0 may indicate success!

 

Create an Indicator on the right side of the array parameter on the Call Library Node and look at the first three values in that array.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 16 of 18
(1,421 Views)
Solution
Accepted by topic author ZhuoCao

Zhuo,

 

functions in C do not work in the manner, that everything in parameters is input, and the return is output.

Your functions takes 1 argument, that is pointer to data, and the function looks where the pointer points, and fills the data with some hw info.

 

After calling this function, you will see the HW info in the array or string you passed as an argument !

 

If your function returns integer, this usually means the error. If you get values like 0 or 1, it is usually success indication, if you get some negative nonsense number, that would be an error number.

0 Kudos
Message 17 of 18
(1,413 Views)

Thank you guys very much for the reply, I now able to get the correct value back from the DLL.

 

untitled.JPG

0 Kudos
Message 18 of 18
(1,400 Views)