NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a char ** (string) from a DLL to TestStand

Hi everybody,

 

I have a DLL (externally supplied) that required a char** parameter – see the function prototype bellow :

int INIT (int Port, char **MessageErreur)

 

Does anyone know what type of TestStand variable use ?

 

 

When I call the function in TestStand 3.5, I obtain the following message : “The parameter information for this function is missing the first array dimension size for one or more parameters. You must enter the correct sizes for these parameters in the Specify Module dialog.”

 

And TestStand defines for the parameter a :

Category : Array of Strings

Type : C String (const)

Dimensions : 1

Dim 1 Size : “Blanc” -> this is why we obtain the error message

 

For me, an array of strings is not correct since I am expecting a string.. of course, I already tried to change the Type and use the Sting Category.

 

Thanks in advance for any help,

Chris

0 Kudos
Message 1 of 4
(4,057 Views)
Hi,
 
I prepared a dll that you can call into TestStand :
The cvidll.dll includes a function named "Function" - here is the prototype : void Function (char **Message).
 
Hope it will help to find a solution to this issue !
 
Chris
0 Kudos
Message 2 of 4
(4,038 Views)
Does the function allocate a string and return a pointer to it? TestStand does not support this prototype because TestStand does not know how to deallocate the memory associated with the string. Instead, TestStand allows you to pass a string buffer that the function can copy strings into.

You can write a wrapper function in another DLL that copies the string into a buffer like this:

void FunctionWrapper(int port, char messageErreurBuffer[], int bufferLen)
{
    char *messageErreurPtr = NULL;

    Function(port,  &messageErreurPtr);

    if (messageErreurPtr != NULL)
    {
        strncpy(
messageErreurBuffer, messageErreurPtr, bufferLen);
    }
}

You can call FunctionWrapper from TestStand.
0 Kudos
Message 3 of 4
(4,024 Views)
Thank you Erik for your answer. Actually, I hoped that there was a way "into TestStand" to deal this issue...maybe in TestStand 5.0.
 
Due to the software architecture of my system, I can not go for another dll..
 
Thanks 
0 Kudos
Message 4 of 4
(4,012 Views)