NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid reloading prototype icon when string paramater in C/C++ adapter?

I have a function in my C++ DLL.

static BOOL InitializeConnection(unsigned char* receivedData, unsigned int* receivedDataLength,

                                                                 unsigned int* errorCode, unsigned char errorMessage[512]);

 

I would like to use a string for the last parameter. When it loads the prototype of function, the type is unsigned char [].

 

When I enter my Locals.str, it give me the error "Expecting nothing, array of number or array of booleans. Found string"

 

If I change in the right panel the Category to String and select the Type "C String Buffer", the error goes away and I receive the string value correctly from my dll.

 

However, I have the red '!" icon flashing next to my function name that says I need to reload the function. Is there a way to get rid of it? I don't want other programmers on my project to hit it and lose all the configuration.

 

 Also, do I need to do something special so when it loads the function, I dont get "arg1, arg2, arg3" as parameter name but the one from my dll?

 

I usually program in C# and it loads correctly the right parameters name.

 

Thank you.

 

-Mat, CTD

0 Kudos
Message 1 of 4
(3,561 Views)
Hi Mat,

If you are loading a C++ function that has the unsigned character array prototype changing the Category to String and Type to C String Buffer from within the C/C++ DLL TestStand code modue will allow the data to be properly passed from TestStand to the DLL. There is not a way to eliminate the red ! that you are seeing after setting this configuration in TestStand. If you have the source code for the DLL, you could change the parameter value to a character array, rather than an unsigned character array and this will elmiminate the problem.

As for the issue of the parameter names not being loaded into TestStand, this is occurring because you are not exporting the prototype symbols with the DLL. Please reference the MSDN Walkthrough: Creating and Using a Dynamic Link Library for setting the  __declspec(dllexport) modifier that will enable methods to be exported by the DLl so they can be used by other applications.

-Adri Kruger
Adri Kruger
National Instruments
LabVIEW Product Marketing
Message 2 of 4
(3,535 Views)

Thanks for the answer Adri.

 

I got rid of the red ! by switching to char instead of unsigned char.

 

For the second part, not being able to see the parameter names, I do use the __declspec(dllexport) at the class level. I switched to the way explained in the tutorial without any difference.

 

class DisplaySeriesComm : public CWinApp
{
public:
    DisplaySeriesComm();
    ~DisplaySeriesComm();

    static BOOL OpenInterface(CCommunication* ptrCom, signed int* errorCode, char errorMessage[512]);
    static BOOL CloseInterface(CCommunication* ptrCom);
    static __declspec(dllexport) BOOL InitializeConnection(unsigned char* receivedData, unsigned int* receivedDataLength, signed int* errorCode, char errorMessage[512]);


...

}

 

I have access to the function in TestStand, the parameters load with the correct types (the column: Description). It's only the names which are set by default to arg1, arg2, ...

 

By comparing to the tutorial, the dll I used is an MFC dll and it also uses a .def file. Not sure if it could be related to that.

 

Thanks.

0 Kudos
Message 3 of 4
(3,528 Views)

The names of the function parameters are not stored in the DLL created by Visual Studio, so TestStand just sets them to arg1, arg2, etc. The names are cosmetic only and do not affect the way the function is called.

 

If you really want to have the parameter names appear in TestStand, you can use a type library to describe the function prototype. TestStand will use the type library if it is embedded within the DLL or if it has the same name as the DLL and resides in the same directory as the DLL.

0 Kudos
Message 4 of 4
(3,509 Views)