NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

passing container data from teststand to labwindows/cvi handle error

Solved!
Go to solution

Hello,

 

I am trying to pass a container parameter from teststand to labwindows/cvi using the UI messages API following this example code created by Peter-R:

 

https://decibel.ni.com/content/docs/DOC-23332

 

This is an excellent example to start off with but as I run it using the extended debbugging level on the build options I see that the containerData object handle is not being released. If I add the CA_DiscardObjHandle(containerData) anywhere in the project it gives me a FATAL_RUN_TIME_ERROR. Should this handle be released? Will it cause memory problems if I call a bunch of these UI Messages? My code right now runs great but I don't want to run into a memory problem later on.

 

Any help on this issue will be great!

 

Thanks in advance.

 

-Luis

0 Kudos
Message 1 of 5
(3,491 Views)

Yes, I think you are correct. You should be calling CA_DiscardObjHandle(containerData); when you are done with that handle. You are getting a fatal runtime error though? What do you mean by adding it anywhere? It should only be added after the code that uses it. You might want to try calling CreateObjHandleFromInterface() rather than using those variant functions. Basically the IUnknown pointer is an interace. You can use IID_IUnknown for the id or something similar.

 

-Doug

0 Kudos
Message 2 of 5
(3,483 Views)

Yes I'm getting a fatal run-time error when I add the CA_DiscardObjHandle(containerData) to the function that uses containerData. Could you provide me with an example of what you just explained in the end about not using those variant functions? Maybe the problem is doing all those conversions? I was just following that example provided by the NI employee. If you have a better way of getting a container from teststand passed to a GUI executable I would like to know.

Thanks,
-Luis

0 Kudos
Message 3 of 5
(3,479 Views)
Solution
Accepted by topic author LG2008

Where are you adding the discard? Maybe you are adding it in the wrong location. You should add it right after the CA_FreeMemory() call as follows:

CA_DiscardObjHandle(containerData);

 

It should work.

 

You can also try the following instead of the variant functions:

 

CA_CreateObjHandleFromInterface (var, &IID_IUnknown, 1, LOCALE_NEUTRAL, 0, 0, &containerData);

 

I think you will still need to discard the objhandle when using this API.

 

-Doug

0 Kudos
Message 4 of 5
(3,467 Views)

I am adding it right after the CA_FreeMemory and I'm still getting a Run-Time Fatal Error. I am using Labwindows/cvi 2010 and Teststand 2010. Maybe this is a bug in one of the NI drivers. Or maybe, using all those variant functions is the wrong way to do this. However, I tried out the code snippet that you posted and it worked great! Thank you for all your help.

- Luis

0 Kudos
Message 5 of 5
(3,444 Views)