07-13-2010 11:11 AM - edited 07-13-2010 11:14 AM
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.
Solved! Go to Solution.
07-13-2010 06:01 PM - edited 07-13-2010 06:03 PM
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
07-14-2010 01:09 AM - edited 07-14-2010 01:11 AM
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)
07-15-2010 12:20 PM
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...
07-15-2010 12:33 PM
The example you gave the path to.