05-22-2013 04:13 AM
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
____________________________________________________
Solved! Go to Solution.
05-22-2013 04:22 AM
05-22-2013 01:28 PM
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.
05-23-2013 12:56 AM
Thanks nathand!
That was the hint i needed
Br Per
03-19-2015 02:50 PM
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?
03-19-2015 03:11 PM
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?
03-19-2015 04:13 PM
Sure.
Attached you could find the snippet of the code I have.
03-19-2015 04:23 PM
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.
03-19-2015 04:38 PM
Thanks a lot for your Help!
I just wired the maxLen to the constant and is working right now.
Best regards.