NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Definition of Result Struct

Each new step type inherites the result struct
property. I want to pass the result struct by
reference to a DLL and therefore need to define
the struct as a C struct. Unfortunately
I'm not able to find a definition of that struct
anywhere - not online, not in the documentation
of TS. Can anyone help?
I use TS 2.0.1/W2K SP3/VC6. Thanks!
0 Kudos
Message 1 of 16
(5,891 Views)
Hi,

Are you referring to tTestData found in C:\TestStand\AdapterSupport\CVI\stdtst.h

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 16
(5,891 Views)
Well I don't know wether I do.
I would like something like that

typedef struct error
{
boolean Flag;
int Code;
char* Msg;
}

typedef struct result
{
error Error;
char* Status;
char* ReportText;
}

Is the above definition the correct one? Where do I find it? Thank you!
0 Kudos
Message 3 of 16
(5,891 Views)
Hi,

The structure is

typedef struct ClassData_Rec
{
int result;
double measurement;
char * inBuffer;
char * outBuffer;
char * const modPath;
char * const modFile;
void * hook;
int hookSize;
tMallocPtr const mallocFuncPtr;
tFreePtr const freeFuncPtr;
struct IDispatch * seqContextDisp;
CAObjHandle seqContextCVI;
char * stringMeasurement;
int tReplaceStringPtr const replaceStringFuncPtr;
tTestData;


Depending on the step type you are using depends on which element to fill with the returning values.
e.g for a Numeric Limit Test - testData->measurement = measurement;


The error is return in a se
perate structure
typedef struct ClassError_Rec
{

Boolean errorFlag;
tErrLoc errorLocation;
int errorCode;
char * errorMessage;
} tTestError;


// OPTIONALLY SET THE ERROR CODE AND STRING
// testError->errorCode = error;
// testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);


The code template has this all nicely setout for you.

You just have to fill in the blanks or put your own code in.

Hope this helps
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 16
(5,892 Views)
I want to use those data structures with a VC++ 6.0 project that will make a dll used with TestStand. Is there anything special I have to do to make it work? I've used this kind of data structures with a CVI dll and in TestStand it detected the parameters automatically. With a VC++ 6.0 dll, the data structure is not detected and I get a system error when trying to run a function with the error structure.
0 Kudos
Message 5 of 16
(5,811 Views)
What system error are you getting?  If you are getting compile errors, probably this post will help.
 
C/C++ dlls are accessed using the C/C++ dll adapter and not the CVI adapter. The adapters can call C-language DLLs, but they use different methods to call these code modules. With the C/C++ adapter you cannot step into code modules like you can with CVI.  However you can always debug a DLL form your C/C++ development environment by launching the seq editor or operator interface as an external process in the development environement.
 
Thank you
Nandini
0 Kudos
Message 6 of 16
(5,794 Views)

TiWi -
MSVC requires 8-byte packing so make sure that your data types for the struct parameters are set properly. LabWindows/CVI in MSVC mode also uses 8 byte packing.  You may want to post your prototype and a sequence with the call to the DLL.  Some of us could take a look at it to see if we see anything that is obvious.

As suggested, if you have source code for the DLL, debugging the DLL and viewing the data passed in is a sure way to determine if you are passing data propertly.

Scott Richardson
https://testeract.com
0 Kudos
Message 7 of 16
(5,796 Views)
To answer your question Nandini, I don't get any compile error but I get a runtime error -17502; System Level Exception. when I run one of the functions from my dll with one of the parameters being the error struct. I am using the C++ adapter for my C++ dll and I defined the tTestError struct in VC++.

 Scott do you mean setting the Default struct packing to 8 byte in TestStand? That is already done. Is there anything that must be defined in VC++ as well?

What I have already done and works is a CVI callback to which I automatically pass the error struct of the step, so whenever there is an error in my dll (a Telnet client) the error code and string are automatically passed back to TS and they are displayed in the report. I took a screenshot of how the step is passing the parameters to the dll. Is there any way to do the same thing with the C++ adapter?

Here is the C++ dll header:

#include <string.h>

typedef int tErrLoc;    /* No longer used but included for backwards compatibility */     
typedef int Boolean;

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

typedef struct ClassError_Rec
    {
    Boolean        errorFlag;        /* The test function must set this to TRUE if an error occurs.  */
    tErrLoc        errorLocation;    /* No longer used, but included for backwards compatibility.    */
    int            errorCode;        /* The test function may set this to a non-zero value if an     */
                                /* error occurs.                                                */
    char *        errorMessage;    /* The test function may set this to a descriptive string if    */
                                /* an error occurs.                                                */
    } tTestError;


void __declspec(dllexport) openAllTrunks(tTestError *errorStruct);
void __declspec(dllexport) closeAllTrunks(tTestError *errorStruct);
void __declspec(dllexport) openTrunk(int TrunkNumber, tTestError *errorStruct);
void __declspec(dllexport) closeTrunk(int TrunkNumber, tTestError *errorStruct);
void openPort(unsigned long BaseAddress, unsigned char RelayAddress, tTestError *errorStruct);
void closePort(unsigned long BaseAddress, unsigned char RelayAddress, tTestError *errorStruct);
void findCards(void);

I am calling either one of the 4 function that are exposed to the dll. Is there any way for TestStand to automatically assign the current step's errorStruct to the errorStruct parameter?

I tried removing the errorStruct parameter, setting the struct parameters values inside the functions and calling those functions and they work as expected.

0 Kudos
Message 8 of 16
(5,783 Views)
Here is a sequence containing a C++ callback to the dll.
0 Kudos
Message 9 of 16
(5,781 Views)
Please see the following knowledge base entry that might be useful to you: http://digital.ni.com/public.nsf/websearch/A92CF6B69941B35D862568D900693DF5?OpenDocument Thanks Nandini
0 Kudos
Message 10 of 16
(5,772 Views)