09-20-2011 10:05 AM
Hi everyone
I am trying to access a dll file for the keterex usb based I2C device and I do not know how to pass data to a double pointer. Here is one of the function prototypes which use the double pointer as an argument:
KX_BOOL kxGetSerialString(KX_ADAPTER adapter, KX_STRING **str);
I have configured the KX_STRING parameter as type string, and as a C String Pointer. The calling convention is stdcall(WINAPI). I have wired a string control to the input and a string indicator to the output.
Thanks for the help!
09-20-2011 10:51 AM - edited 09-20-2011 10:52 AM
Looking at the manual for that device (I assume USB-910H?) KX_STRING is a ASCII null terminated string, so in C this is pointing to an array of unsigned chars. Set the KX_STRING param in the CLFN (call library function node) as Type: numeric, Data type: unsigned pointer sized int and Pass: pointer to value. This should return a value of size pointer that points to a string.
Now, if you tell me which LabVIEW version you have I can write a VI (using LabVIEW provided dll functions) for that version which takes this pointer and outputs the string. Basically, a double pointer is a pointer to a pointer, so once we have the first pointer returned by this function we can look where it's pointing to in order to get the actual string.
M
09-20-2011 11:01 AM
Thanks for the reply myle00. I am using labview 2009 sp1. Looks like I will have to tinker with this for a bit, ti crashed after I changed the parameters for KX_STRING.
09-20-2011 11:04 AM
Can you provide the DLL so that I can test it? Or maybe there's a place to downloaded it from? Also, are you on 32 or 64 bit LabVIEW?
09-20-2011 11:15 AM
I am using the 32 bit version of labview. You are right by the way I am using the 910h, forgot to mention that important piece of info. Check out the vi I created for it also.
I attached a vi and the header file, but it wont allow me to attach the dll. You can download the control center software from here and will find the header file, dll, and library file in the keterex directory after installation.
http://www.keterex.com/kxusb910h.php
Here is a list of all the api functions:
09-20-2011 11:35 AM
Try the VI attached. You'll of course have to reselect the path to the DLL.
Let me know if it works.
M
P.S. the reason it crahsed is that it shouldn't have been set to stdcall but to C.
09-20-2011 11:46 AM
That works perfectly! Are the winapi strictly for windows functions? I dont think I have the full understanding of when to use that. Also, where is the labview library located?
Thanks for the help!
09-20-2011
12:08 PM
- last edited on
05-28-2025
01:29 PM
by
Content Cleaner
As a user, the use of stdcall vs c depends on how the functions were declared - you have to set it to the same way it was declared. If you look in kxusb910h.h, each function is prefaced with the KXUSB_API macro which expands to "extern "C" __declspec(dllexport)" (if you're working in C++, see the top of kxusb910h.h). So since these functions were declared with C you have to call them that way too. The reason for declaring the functions one way or another depends on how and where you call them.
See also the "Setting the Calling Convention" section here: https://www.ni.com/docs/en-US/bundle/labview/page/configuring-the-call-library-function-node.html
The functions I called on LabVIEW are declared here:C:\Program Files (x86)\National Instruments\LabVIEW 2011\cintools\extcode.h. You access the functions by typing LabVIEW (note the caps) in the dll path and it'll list all the available functions.
Matt