LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer an arrary in CVI DLL to Teststand Arrary variable

    I have an "Arrary of unsigned char" in CVI DLL and need to be transfered to Teststand GlobalFiles.RxStr (RxStr is an array of number) I know I have a potential choice to use "TS_PropertySetValVariant", but don't know how to do that, because everytime when I try to do this, there comes an error: Found "pointer to unsigned char, expected Variant".
    Arrary of unsigned char:
[31,
44,
5A,
03,
1E]
    Expected GlobalFiles.RxStr: (decimal format)
[49
68
90
03
30]
0 Kudos
Message 1 of 7
(3,933 Views)
Jacky,
I may be confused about what you are trying to do, and it has been a while since I have used test stand, but I am going to take a crack at it.  I assume you have a dll with a function that returns a char array that you are trying to get into a test stand number array.  Create a local variable for the step that you can pass into the function.  The exact type you need I have forgotten, it may be string, or it may be an array of characters directly in the step, I cannot remember the options under test stand, but test stand 3.0 could handle almost any data type.   
Once the function has returned the data in the char array you can use a post step to copy the data from the char array to the global number array, one number at a time.
 
A variant type is not going to work for this.  The function in the dll would need to changed to accept a variant type in place of the char array.
0 Kudos
Message 2 of 7
(3,906 Views)
I got a solution by refering to the context help for TS_PropertyGetValVariant.
 
Thanks!
Jacky
 

Example

LabWindows/CVI
    VARIANT tmpVariant = CA_VariantEmpty();
    double *numArray = NULL;
    unsigned int numElements;

    TS_PropertyGetValVariant(propObj, &errorInfo,
                             "Locals.NumArray", 0, &tmpVariant);
    CA_VariantGet1DArray(&tmpVariant, CAVT_DOUBLE, &numArray,
                         &numElements);

    CA_FreeMemory(numArray);
        CA_VariantClear(&tmpVariant);

0 Kudos
Message 3 of 7
(3,904 Views)

Hi Jacky,

There is an example in the Teststand examples folder that should help you with this.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 7
(3,850 Views)

Hi jacky,

The propObj this needs to be the SequenceContext reference. How have you derived this reference?

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 5 of 7
(3,848 Views)
When you build your DLL, see below, the handle "seqContextCVI" is just what you want
int DLLEXPORT PTP_StepType(CAObjHandle seqContextCVI)
{
 /* Call this function from the appropriate place in your code */
 // to load and display startup panels.
 
 short errorOccurred=0;
 long errorCode=0;
 char errorMsg[1024];
....
....
 
 
 
Thanks
Jacky
0 Kudos
Message 6 of 7
(3,832 Views)

Hi,

Ok, so why are you not doing this;

    TS_PropertyGetValVariant(seqContextCVI, &errorInfo,
                             "Locals.NumArray", 0, &tmpVariant);

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 7 of 7
(3,828 Views)