03-26-2013 03:04 PM
I need to run through some test steps in a TestStand sequence multiple times. This wouldn't be a loop on a single step or group of steps but probably a goto a label "for" loop in TestStand. BTW, TestStand 2.0.1 calling code from a LabWindows/CVI DLL via the standard prototype adapter. Each iteration I need to have the test step limit names be updated with a different suffix. So step1 might have results0 and results1 and on the 2nd run results0 would be renamed to results0b. How do I update the limit names, at run-time, from a LabWindows/CVI function? I.e. the first test in the sequence's Main would update the steps below it to update the suffix. I started down the path of using TS_SeqContextGetProperty to get the sequence handle
TS_SeqContextGetProperty( testData->seqContextCVI, &errorInfo, TS_SeqContextSequence, CAVT_OBJHANDLE, &seq_hndl );
then using TS_SequenceGetNumSteps( seq_hndl, &errorInfo, TS_StepGroup_Main, &num_steps ) to determine the number of steps in the Main tab.
Enter a for loop:
TS_PropertyGetValString( testData->seqContextCVI, &errorInfo, buf, TS_PropOption_NoOptions, ( char ** )&rslt_name ) with buf as "Sequence.Main[0].Result.Measurement[0]" errors out with an invalid name message. The idea is to get this value, update it based on the iteration in TestStand ( this is already acquired and working ), and then set the value back. Then, move on to the next step and so forth.
Any suggestions?
Thanks.
Solved! Go to Solution.
03-26-2013 03:49 PM
I think I found what enough guidance here: http://zone.ni.com/devzone/cda/epd/p/id/1181.
06-13-2013 02:56 PM
So, I tried the example and it works but only for a single step. I've tried two options: 1. having a single step that programmatically changes all the result names in all the other steps in the sequence. 2. having each step update the result names itself. For thought 1 the loop would run and the changes would occur but when the function was exited I'd get an exception from TestStand. No real information in the details as it looked like a memory corruption error. I then examined the details of what occurred and tried more experiments. If I had the loop have more than 1 iteration this behavior occurred. If I comment out the set function it still occurs. Then, for thought 2, it works like a champ on all the steps until I loop back to the top of the sequence. Then, on the first step ( 2nd time through ) it bombs out.
Attached is the code for the 2nd possible solution.
Does anyone know what the problem is or if there's a way to do this?
06-16-2013 09:47 PM
Hello Grasshopper,
What do you mean by "it bombs out"?
An error code or message can be helpful to know why this is happening.
06-17-2013 08:47 AM
TestStand throws an exception and says memory can't be read at some address ( it varies ). -17502 is the TestStand code.
06-18-2013 05:09 PM
Unfortunately, TestStand error numbers are not exclusive, so it might not be any of the below cases.
I saw a case where this error could be caused by not properly declaring variables used by the DLL function.
It could also be that the DLL is not properly released after the first run, thus causing the error during the second run.
Another time it shows up is when CA_DiscardObjHandle and CA_FreeMemory are not correctly used.
It seems to be a memory related issue, as you mentionned. Let me know if it's any of the above situations.
06-18-2013 09:10 PM
I had freed a string with CA_FreeMemory and then didn't set it to NULL. At the very end of my function I check for unfreed handles/strings and free. In this case, the freed memory was being freed again since CA_FreeMemory only doesn't free the memory if the argument is NULL.
Thanks.