From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

teststand API

Solved!
Go to solution

Hello,

 

I am creating a CVI interface that runs a Teststand sequence. I want to set/get variables from the StationGlobals of Teststand. I use this code to get a string: 

if (TSTD_GetStationGlobalsString(ERR_RETURN_PTR, "TS.LastUserName", &result) < 0)
          printf("fail\n");
else
          printf("%s\n",result);

 

and the function TSTD_GetStationGlobalsString is as below:

 

int TSTD_GetStationGlobalsString( ERR_RETURN_DECLARATION, char* lookupString, char** pString )
{
int error = NO_TB_ERROR;
ERRORINFO errorInfo;
char* pTempString;


ERR_RETURN_INIT_NO_ERROR;

errChk (TS_PropertyGetValString (gStationGlobalsHandle, &errorInfo, lookupString, 0, &pTempString));

*pString = malloc(strlen(pTempString)+1);

strcpy(*pString, pTempString);

Error:

if (pTempString != NULL)
{
CA_FreeMemory(pTempString);
}
if (error != 0)
{
strcpy(*pString, "");
return -1;
}
else
{
return NO_TB_ERROR ;
}

}

 

this is working, howerver when I want to access another variable diffrent from TS it doesn't. Can someone help me please.

 

Thank you.

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

What are you using as your lookup string?  If I have a StationGlobal called Foo then I need to pass just "Foo" as my lookup string.

 

Also, make sure the the StationGlobal exists or it won't work.  You can either use the PropertyExist method or use the InsertIfMissing flag (0x1).

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 6
(4,673 Views)

Hello,

 

Thank you for your help, I use "toto" as a lookup string, it's a string variable that I have added to the sequence. I have also checked the StationGlobal handle while debugging and it is not NULL. but it looks like it only has the defalut variables. 

Edit: I actually cheked the station global using PropertyExist method and it returns True.

 

Thank you

0 Kudos
Message 3 of 6
(4,651 Views)

Sorry 

 

PropertyExist method returns False.

 

Thank you

0 Kudos
Message 4 of 6
(4,642 Views)
Solution
Accepted by Olfa

Hello,

 

Problem solved, I only had to restart Teststand to save the new Sation Global ^^' 

 

Thanks Smiley Embarassed 

0 Kudos
Message 5 of 6
(4,628 Views)

Glad you figured it out!

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 6 of 6
(4,618 Views)