11-18-2013 06:03 AM
Hi,
I'm having some issues getting the following to work.
I have a device from a manufacturer that came with it's own .dll and header files. I am trying to call the .dll from LabVIEW (2011). There are about 50 functions in total, and there is one remaining which I cannot get to work (probably because I don't understand enough about the topic of interfacing with external code).
The .dll description comes with the following:
#define MAX_LEN
#define MAX_CONFIGURATIONS
Prototype: int ConfigListGet (char (&sConfigurations)[MAX_CONFIGURATIONS][MAX_LEN]);
and the header file with:
extern "C" __declspec(dllexport) int RepRateConfigurationListGet(char (&sConfigurations)[MAX_CONFIGURATIONS][MAX_LEN]);
The function should return an array of strings for a list of configurations.
The problem I am having is that I cannot figure out how to return the array of strings to the LabVIEW Call Library Function Node. I have looked quite a bit around the web and at the examples in LabVIEW and I can't find anything specific to returning an array of Strings in this way, so if anyone can point me in the right direction I would really appreciate it.
Also, if I right click the Call Library Function Node and click "Create .c File", should I be able to create the same function prototype as above? I tried this but had no luck. The closest I came was:
int32_t RepRateConfigurationListGet(char sConfigurations[], uint8_t MAX_CONFIGURATIONS, uint8_t MAX_LEN);
Many thanks in advance for any help!
D
Solved! Go to Solution.
11-18-2013 06:40 AM - edited 11-18-2013 06:41 AM
Hi!
I tried once using an array of U8, converting it to a string and then splitting it in an array.
Here's my old piece of code (the split part can be cleaner ;=) )
Regards,
Marco
11-18-2013 06:58 AM
Marco,
You are a genius! Thank you so much!
I'm assuming we are programming the same or similar device?
Out of interest, did you have any luck with Rep Rate Parameters Get \ Set? I had trouble passing the Enum in that cluster, LabVIEW keeps crashing.
Thanks again,
D
11-18-2013 07:39 AM
Couple of other things that I would like to add:
Not sure if you have access to the header files to the dll, if you do this is pretty handy http://zone.ni.com/reference/de-XX/help/371361K-0113/lvexcodeconcepts/importing_shared_library/
Also this example that ships with LabVIEW was very useful for me in the past: C:\Program Files (x86)\National Instruments\LabVIEW 2012\examples\dll\data passing
11-18-2013 07:46 AM
Hi .aCe.,
I do have the header files, however LabVIEW does not import all the functions correctly (in 2011 anyway....). There were three of the functions that didn't work correctly after importing.
1 - Contained a complex data type - a structure with integers, doubles, strings, enum, and a boolean. This was a mess, LabVIEW added a lot of "dummy controls". I still haven't managed to get this working.
2 - where "int" is defined in the header file, LabVIEW was unable to distinguish between what type of integer. But that's fair enough, how would LabVIEW know?
3 - The Import Library function by default was returning only the first line of an array, as opposed to the actual array. Not sure why this happens.
As you said, it is a very good function, but it's not always 100% unfortunately.
D
11-18-2013 09:42 AM - edited 11-18-2013 09:42 AM
Out of interest, did you have any luck with Rep Rate Parameters Get \ Set? I had trouble passing the Enum in that cluster, LabVIEW keeps crashing.
Unfortunately no, I didn't.
If I have time I'll try again and let you know....
Marco