03-15-2010 04:23 AM
Hi,
In the past we used Teststand 2.0.
We used the comment field of a step to pass variable to CVI.
We used the following code to do this
tsErrChk (TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo,TS_SeqContextStep, CAVT_OBJHANDLE,&objhStep));
tsErrChk (TS_StepAsPropertyObject (objhStep, &errorInfo, &objhPropertyObject));
tsErrChk (TS_PropertyGetProperty (objhPropertyObject, &errorInfo,TS_PropertyComment, CAVT_CSTRING, &CommentStr));
Now, we use Teststand 4.2. In Teststand 4.2 the argumentlist of a function has changed. So this code does not work.
How can i read the comment field from a teststep in Teststand 4.2 into CVI 8.1 ?
How can i get the name from the used seq file in CVI 8.1 >
Thanks in advance
Tonnie
03-15-2010 08:56 AM - edited 03-15-2010 08:57 AM
All of these APIs should still work. Which prototype has changed? What error are you getting? There is a new way to get properties, there is a separate function for get and set of each property, but the old one you are using is still supposed to work, so please let us know which ones are giving you problems. The new APIs, in case you want to use them, are TS_SeqContextGetStep and TS_PropertyGetComment.
Hope this helps,
-Doug
03-15-2010 01:46 PM
Hi
I have added the seqContextCVI object to the argumentlist of my function
void __declspec(dllexport) Meet(double *measurement, char reportText[1024], short *errorOccurred, long *errorCode, char errorMsg[1024], CAObjHandle seqContextCVI)
{
int error = 0,State=0;
ErrMsg errMsg = {'\0'};
ERRORINFO errorInfo;
static CAObjHandle objhPropertyObject, objhStep;
static char *CommentStr1,*CommentStr2;
//First try
tsErrChk(TS_PropertyGetComment (seqContextCVI, NULL, &CommentStr));
sscanf (CommentStr1, "State=%i",&State);
//Second try
tsErrChk (TS_SeqContextGetProperty (seqContextCVI, &errorInfo,TS_SeqContextStep, CAVT_OBJHANDLE,&objhStep));
tsErrChk (TS_StepAsPropertyObject (objhStep, &errorInfo, &objhPropertyObject));
tsErrChk (TS_PropertyGetProperty (objhPropertyObject, &errorInfo,TS_PropertyComment, CAVT_CSTRING, &CommentStr2));
sscanf (CommentStr2, "State=%i",&State);
*measurement = testMeasurement;
Error:
if (error < 0)
{
// *errorOccurred = TRUE;
// OPTIONALLY SET THE ERROR CODE AND STRING
// *errorCode = error;
// strcpy(errorMsg, errMsg);
}
}
I treid to read the comment field in 2 different ways
The first way is not working. The second way works fine.
Why is the first way not working
Thanks in advance
Tonnie
03-15-2010 05:54 PM
Which code specifically is the one that works and which is the one that doesn't. It's unclear whether you mean the first post or the call to TS_PropertyGetComment in the second post. In the second post you are getting the comment of the sequence context, is that what you intended? I thought you wanted the comment on the step.
Also, are you sure there is a problem with getting the comment? Maybe the problem is that the comment you are getting does not have the string you are expecting in it, thus sscanf is failing.
Also there are a couple of issues with your code:
1) Your local variables should not be static. The static keyword will make them global variables, thus making your code not thread safe. There does not appear to be any need or reason for them to be static.
2) You need to initialize your CAObjHandle local variables to 0 and your char * variables to NULL and then, after the error label you need to free them or you will be leaking objects and memory. Call CA_DiscardObjHandle() on the object handles to free them (NOT the ones passed as parameters, only the ones you got from function calls), and call CA_FreeMemory() on the strings (i.e. the char * variables, again, only the ones you got from function calls).
Hope this helps,
-Doug