NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

pass arrays by reference from a CVI function to TestStand

Solved!
Go to solution

i need to pass arrays (of doubles, for instance) from a CVI function (typically a dll), back to TestStand.  and vice versa.

 

I'm following a method that uses TestStand CVI functions such as "TS_PropertyGetValNumber" and "TS_PropertySetValString", and I understand how to do single values, but arrays are killing me.   I can't imagine why this would be so difficult, so I must be missing something fundamental

 

Here is a simple example of what i'm doing.   i need to add a way to pass an allocated array of doubles (as declared and held in TestStand) into the CVI function where it is called "values", have my CVI function populate that array of "values", and then pass the array back.    

 

 

void TestStand_DUT_Transfer (CAObjHandle seqContextCVI, char reportText[1024], 
                             short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    int error = 0;    
    char response [DUT_TS_MAX_BUF_SIZE] = {'\0'};    
    double delayResponse = 0.0;
    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;

    // get double value from TS
    tsErrChk (TS_PropertyGetValNumber (seqContextCVI, &errorInfo, "Properties.Delay",
                                       TS_PropOption_NoOptions, &delay));
    
    /*                                                                     */
    /*    HOW WILL I GET AN ALLOCATED ARRAY OF DOUBLES FROM TEST STAND?    */
    /*                                                                     */
 
    // send command to device, receive a response string and array of double values in return
    
DUT_TS_ErrChk (DUT_Transfer (delay, response, values)); //<=== here is "values" array
/* */ /* HOW WILL I PASS BACK THE VALUES BACK TO TEST STAND? */ /* */ // send char string to TS tsErrChk (TS_PropertySetValString (seqContextCVI, &errorInfo, "Properties.DUTResponse", TS_PropOption_NoOptions, response)); Error: if (error != NO_ERROR) { DUT_Error_Handler (error, errMsg); *errorOccurred = TRUE; *errorCode = error; strcpy(errorMsg, errMsg); } }

 

 

thank you for considering.

 

 

0 Kudos
Message 1 of 5
(4,591 Views)
Solution
Accepted by topic author rjohnson

okay, I got an answer from NI Support.  I guess it's a common question since they have an Example written, but for future reference (since I couldnt find an answer by searching the forums), I'll post it here:


<TestStand 4.2.1>\Examples\AccessingArraysUsingAPI\UsingCVI


0 Kudos
Message 2 of 5
(4,575 Views)

Hi,

 

This example is based on TestStand 2.x interface and although it's still valid, you could of passed your array back into teststand directlly via the code modules parameter list ie myfunction (double * mydata)

 

Regards
Ray Farmer
0 Kudos
Message 3 of 5
(4,561 Views)

Hi Ray,

 

thanks for replying.   when you  say "this example"  what do you mean, is there supposed to be a link?  I don't see anything...

0 Kudos
Message 4 of 5
(4,533 Views)

The example you gave the path to.

0 Kudos
Message 5 of 5
(4,531 Views)