LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass pointer of character array type with DLL

Solved!
Go to solution

Hello,

 

I'm developing a controller application for a Wavelength Meter (WSU 10 from HighFinesse) and I'm having some troubles with the use of the DLL.

In order to get one parameter from the meter, I have a Call Library Function Node to which I have to pass, according to the WSU manual:

 

"A pointer of character array type which receives the PID course. The character array must be declared with 1024 Bytes size (including the terminating zero) and initialized"

 

I've tried out several ways as it is explained in these manuals:

http://digital.ni.com/public.nsf/allkb/2AC115DFF7DC64308625716B005AF58D

https://decibel.ni.com/content/docs/DOC-9080 

 

But I'm not able to get it to work. When I run the application it says that the VI stopped working. 

 

How can I pass these type of argument? Any help would be very much appreciated.

Thank you.

 

BR.

0 Kudos
Message 1 of 10
(3,840 Views)

Here is my last attempt. I can't see why it doesn't work.

 

Captura.PNG

 

And here is the configuration of the Call Library Function Node:

(The first argumen ('1') is just the port number I'm using)

 

Captura2.PNG

 

Any idea?

Thanks in advance.

0 Kudos
Message 2 of 10
(3,813 Views)
are you sure your function does not need any output argument ?
0 Kudos
Message 3 of 10
(3,800 Views)

This looks correct, but can you attach your VI instead of a screenshot? Are you sure that you're using the correct calling convention? Are you able to call other functions in the same DLL successfully? What is the exact error that you get when you try to run this function? Are there calls to any other functions in the same DLL running at the same time as this call, and if so, is the DLL reentrant? How is the function that you want to call declared - can you provide the function prototype (from the .h file) and documentation for the function?

0 Kudos
Message 4 of 10
(3,797 Views)

Thank you both for your answers.

Attached you will find two VIs. In the working one I've been able to call other functions (getWavelengthNum functions) in the same DLL successfully, as you can see in this screenshot:

 

working.PNG

 

I have to say that I'm running these applications in a different computer to the one where I'm developing them, because I can't have LabVIEW installed in the computer where the Wavelength Meter is connected to. Therefore, I'm using Application Builder to create .exe files. Having said that, in the previous image you can see that it's working properly.

 

In the other VI file (not working one), I've just added another Call Library Function Node with the GetPIDCourseNum function. You can find this function in the attached manual (page 100). Here is an screenshot:

 

getPIDCourseNum.PNG

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

In the next screenshot you can see the error I get when I try to run this VI:

 

not working.PNG

 

 

In the header file (wlmData.h, also attached), the function prototype is:

 

Data_API(long) GetPIDCourseNum(long Port, sref PIDC) ;

 

I really appreciate your help.

Best regards.

 

 

 

0 Kudos
Message 5 of 10
(3,789 Views)

Here you will find the dynamic library and the header file.

0 Kudos
Message 6 of 10
(3,785 Views)
Solution
Accepted by topic author pablopaolus

Check the calling convention. You have GetPIDCourseNum configured as "C" but the other working calls are configured as "stdcall" and the documentation says "All functions have to be declared with the library name ‘wlmData.dll’ and the ‘stdcall’ calling conventions" (page 115, section 4.1.7.4 LabVIEW).

 

EDIT: if that doesn't fix it, try setting the Error Checking level to "Maximum" in the Call Library Node configuration, and also try setting all calls to run in the user interface thread, or chain their error wires together so that only one call to the DLL executes at a time.

Message 7 of 10
(3,783 Views)

For me changing calling convection from C to stdcall is working just fine on my Laptop.

Check for yourself.

0 Kudos
Message 8 of 10
(3,764 Views)

That was it! Now I don't get the error message. I can't tell you if it's reading the PID value correclty because I can't switch the lasers on right now, but I'll let you know. 

Thank you very much!!

0 Kudos
Message 9 of 10
(3,748 Views)

It's reading correctly 🙂

Thank you again.

0 Kudos
Message 10 of 10
(3,740 Views)