LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL array of ASCII chars?

Solved!
Go to solution

Hi I’m having trouble setting up the parameters for calling a "array of ASCII chars" DLL function.

 

How do I set the parameters for a array of ASCII chars?

(all my other function are working ok its only the array of ASCII chars function I can’t get to work)

 

The DLL function looks like this:

____________________________________________________

int32 teGetAvailableSpiPorts(

 uint16* maxLen,

 char* ports,

 char* trans,

 uint16* count

);

 

Parameters

maxLen

Size of the arrays pointed to by the ports and trans parameters. If this parameter indicates that the ports or trans arrays are too small to store the complete strings, then the value is set to the size required (and error is returned). If any other error occurs, this value is set to zero.

 

ports

Pointer to an array of ASCII chars where the comma separated list of available SPI port names will be stored. These are readable names which could be used for user selection.

 

trans

Pointer to an array of ASCII chars where the comma separated list of SPI transport options for each of the available ports will be stored.

 

count

This value is set to the number of available ports found.

 

Return Values

0 = Error

1 = Success

 

____________________________________________________

0 Kudos
Message 1 of 9
(3,134 Views)
0 Kudos
Message 2 of 9
(3,133 Views)
Solution
Accepted by topic author pern

Pre-allocate an array of maxLen bytes (U8) using Initialize Array. Then use Byte Array to String to convert that to a string; this gives you a string of maxLen characters. Configure the Call Library Function for that parameter as a C string, and wire your pre-allocated string to it. The DLL will fill the string, and the string output is on the output side of the Call Library Node opposite the input. You can wire the same string to both ports and trans since they use the same length; LabVIEW will automatically make a copy so that you'll be passing two different strings.

0 Kudos
Message 3 of 9
(3,103 Views)

Thanks nathand!

 

That was the hint i needed Smiley Happy

 

Br Per

0 Kudos
Message 4 of 9
(3,086 Views)

Hi Pern, 

 

I'm having the same problem and I tried what Nathand indicated but I'm still not able to get the values of port and trans.

 

Could you be so kind to share with me how did you do to make this work?

 

 

0 Kudos
Message 5 of 9
(2,988 Views)

If you post your code, it will be easier to help you. Do you get any values from ports and trans? What's the return value from the function? Is there an error on the Call Library Function Node error output?

0 Kudos
Message 6 of 9
(2,980 Views)

Sure.

 

Attached you could find the snippet of the code I have.

 

GetAvailableSpiPortsSnippet.png

0 Kudos
Message 7 of 9
(2,968 Views)

I'm still on LabVIEW 2012 so I can't open your snipped in LabVIEW, but just from the image I can see that you have not configured the Call Library Function Node correctly. The maxLen parameter is a pointer, and should have an input in addition to the output. As defined in the first message in this thread, the maxLen parameter as an input should contain the length of the ports and trans strings. Since you're not passing any value, most likely it's seeing a length of 0, and you're not getting anything in the string outputs.

 

Configure the maxLen parameter to be passed by pointer, and connect the "256" constant to it.

Message 8 of 9
(2,963 Views)

Thanks a lot for your Help! 

 

I just wired the maxLen to the constant and is working right now.

 

Best regards.

0 Kudos
Message 9 of 9
(2,957 Views)