LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Return String Array from Call Library Function Node

Solved!
Go to solution

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

 

 

 

0 Kudos
Message 1 of 6
(3,452 Views)
Solution
Accepted by labview_dave

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

 

arrayofstrings.png

Message 2 of 6
(3,437 Views)

Marco,

 

You are a genius! Thank you so much!

 

I'm assuming we are programming the same or similar device? Smiley Happy

 

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

0 Kudos
Message 3 of 6
(3,425 Views)

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


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 6
(3,402 Views)

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

 

0 Kudos
Message 5 of 6
(3,400 Views)

 

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

0 Kudos
Message 6 of 6
(3,387 Views)