Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

close multiple serial port instances

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

0 Kudos
Message 1 of 9
(4,509 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 9
(4,501 Views)

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

0 Kudos
Message 3 of 9
(4,494 Views)

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.

0 Kudos
Message 4 of 9
(4,488 Views)

You are probably talking about the abort button instead of the stop button.

You should disable that button, because it can do weird things with your controller, giving half commands or even single characters

greetings from the Netherlands
0 Kudos
Message 5 of 9
(4,483 Views)

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.

0 Kudos
Message 6 of 9
(4,471 Views)

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.

greetings from the Netherlands
0 Kudos
Message 7 of 9
(4,464 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(4,456 Views)

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

0 Kudos
Message 9 of 9
(4,452 Views)