04-20-2011 02:56 AM
Hi,
I have not been able to judge or find the best practice to pass arrays between TestStand and CVI. I would have preferably done it by passing pointer to array. For Example, if I have a function written in CVI dll:
int GetAverage (double* aBuffer, double aSize, double* aAverage)
In TS I have an array double aBuffer[100]:
- I can not pass simply
GetAverage (aBuffer, 100, &aAverage)
- nor I can pass:
GetAverage (&aBuffer[0], 100, &aAverage)
- The only thing which TestStand Accepts is:
GetAverage (aBuffer[100], 100, &aAverage)
Which I do not find good becasue size is just repeated.
I have had no issues if I could write
GetAverage (aBuffer[100], &aAverage)
but problem is in this case there is no possiblity fo CVI to determine the size of array, as sizeof(aBuffer) just returns, sizeof(double).
Can you provide me hint to best programming practice in this case?
Regards
RB
Solved! Go to Solution.
04-20-2011 04:14 AM
Hi,
Have you checked out the example supplied with TestStand.
04-20-2011 04:33 AM
Hi Ray,
After seeing examples I starting writing code the way you see above.
The array with size is passed:
GetAverage (aBuffer[100], &aAverage)
But thing is in such a case, I do not know the size of array, which is important for me to know as I have to iterate through the array to find its average.
That was the reason why I posted my question to know the size of array few days ago. sizeof is not adviced usually and giving size 2 times is something user might not like. First, it is repition and second if by mistake these 2 values are not same, then the program will produce undesirable results.
Sorry, in case you discover that I missed to see one example which would have helped me providing solution to this issue.
Regards,
RB
04-20-2011 05:23 AM
Hi,
You need to pass the 100 to the function as a separate parameter.
04-20-2011 06:21 AM
HI
Just as additional:
There is another way for accessing arrays.
Often i use for this task the TS-API. The only parameter you need is the Sequence Context.
May be you should also visit this Example:
TestStand 2010\Examples\AccessingArraysUsingAPI\UsingCVI\AccessingArrays.seq
Regards
Juergen
04-20-2011 06:31 AM
Hi,
Yes this example uses the old method of passing data too and from teststand (ie pre version 3.0) but is still a perfectly valid method. This is the example I was referring about.
04-20-2011 06:51 AM
sorry for overseeing this example. Looks good.
11-17-2017 05:28 AM
Quite old thread but fit my need: we have a structure in Teststand and the same in CVI, but when one changes, it is very difficult to check if they are consistent.
I checked support forum, just reaching this thread.
Do you have a better version of this old version (<3.0) for Teststand 2016?
R1