06-05-2013 04:29 AM
Hi All,
This has been annoying me for a while but I have never bothered to look into it until now!
I have a VI that is used fo developing tests. I communicate with a serial device through com1.
The people using this VI regulary shutdown the VI without using the GUI and the shutdown button. On the next intialise a new comport port reference is instantiated and after a while this cna grow to be quite big so that it appears a list appears in the visa control,e.g.
com1
com1(1)
com1(2)
com1(3)
com1(4)
Also, see attached screenshot.
VISA FIND RESOURCE only shows the aliases and not the instances.
Is there a way that I can look at all the open references and close them all programmatically before initiating a new reference?
Thanks,
Sean
06-05-2013 07:38 AM
How are they shutting down the VI? The X in the window title bar? You can catch that with the Panel Close event. Then you can properly shut down your VI instead of letting it go into limbo.
06-05-2013 08:48 AM
Hi crossrulz,
They are stopping the VI mid-execution by hiting the stop button mainly, although x's do happen too.
I'd like to keep complexity out of the VI, so rather than having an event listener I want to shutdown any open references during the serial port initialization routine.
If I could list the open sessions, then I could just close them before the Vi commence. That would stop the build up of references and stop people asking me if it is broke becasue their are so many references.
-Sean
06-05-2013 09:48 AM - edited 06-05-2013 09:49 AM
SeanJ,
Create a functional global to handle the serial port. Keep the references in uninitialized shift register. You can then set your code up to attempt to close references on startup.
06-05-2013 09:51 AM
06-05-2013 10:41 AM
Hi Albert,
The VI is used by engineers who want functionality. The ability to abort, view block diagrams, insert probes, etc.
It's not intended for operators at the moment and an engineer could just re-enable the button. Ok, it could be password protect but the code is meant to be shared and developed by multiple people with abilities ranging from basic to advanced.
The simpler the design the better.
06-05-2013 10:46 AM
I understand the simpler the better, but abort is something we try to relearn to our users that some instruments can go wild and will go wild.
So a window close would be nice to handle the real close and then no abort is necessary anymore.
But anyhow I'm also working in a research environment so I know what you feel.
Good luck.
06-05-2013 11:30 AM
What I do is hide the toolbar when running (VI property in the Window Appearance tab). Then your code should have an abort so that you can clean up any resources. The best way to fix the issue is to not let it happen in the first place.
06-05-2013 11:39 AM
Hi Wayne,
That's a good idea. I'd still prefer to be able to use labVIEW to programmatically list the open serial port references but if I can't I will use your suggestion.
The only problem would be if someone closed the references with different code but I guess I could handle that. Still it must be possible to find and list the open sessions. I'd a good look through activex and .net. The devicemanger is bizaare as the count reads zero even though it cannot possibly be zero. It might be possible to reset the serial card using the activex devicemanager but it's not possible on the standard device manger interface so probably a waste of time.
Unless there is a way of doing this directly, I'll go with your suggestion.
Thanks,
Sean