11-04-2013 07:24 AM
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.
Solved! Go to Solution.
11-04-2013 10:17 AM
Here is my last attempt. I can't see why it doesn't work.
And here is the configuration of the Call Library Function Node:
(The first argumen ('1') is just the port number I'm using)
Any idea?
Thanks in advance.
11-04-2013 11:29 AM
11-04-2013 11:48 AM
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?
11-04-2013 01:18 PM
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:
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:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In the next screenshot you can see the error I get when I try to run this VI:
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.
11-04-2013 01:25 PM
Here you will find the dynamic library and the header file.
11-04-2013 01:26 PM - edited 11-04-2013 01:28 PM
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.
11-04-2013 08:46 PM
For me changing calling convection from C to stdcall is working just fine on my Laptop.
Check for yourself.
11-05-2013 05:24 AM
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!!
11-05-2013 07:20 AM
It's reading correctly 🙂
Thank you again.