NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to pass an array between TestStand to CVI

Solved!
Go to solution

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

0 Kudos
Message 1 of 8
(4,674 Views)

Hi,

 

Have you checked out the example supplied with TestStand.

 

Regards
Ray Farmer
0 Kudos
Message 2 of 8
(4,673 Views)

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

0 Kudos
Message 3 of 8
(4,669 Views)

Hi,

 

You need to pass the 100 to the function as a separate parameter.

Regards
Ray Farmer
0 Kudos
Message 4 of 8
(4,667 Views)
Solution
Accepted by topic author dotNet_to_LabW

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

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 5 of 8
(4,662 Views)

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.

 

 

Regards
Ray Farmer
Message 6 of 8
(4,659 Views)

sorry for overseeing this example. Looks good.

0 Kudos
Message 7 of 8
(4,655 Views)

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

0 Kudos
Message 8 of 8
(3,294 Views)