08-04-2010 09:56 AM
I am debugging a program that communicating through my serial port. Since I am debugging, many times, I need to stop the program before I close the comm port in the program. Is there a way to manually free up the comm port? Thanks!
08-04-2010 10:02 AM - edited 08-04-2010 10:02 AM
Create a simple VI that has the VISA Close function and the VISA resource as a control. Set the VISA control to be your com port. Hit the run button. It will close the port.
08-04-2010 10:19 AM - edited 08-04-2010 10:20 AM
You could also temporarily turn on the "Automatically close VISA sessions" option in the "Environment" section of the LabVIEW options. I say temporarily because if you do a lot of work with instruments, having this on is a real PITA.
08-04-2010 10:34 AM
While Bill's method WILL WORK there is another easy way to accomplish this.
From Tools>Options select Automatically close VISA sessions. With this set when a vi stops or is stopped any VISA resources are released
To demostrate the functional differance run the snippet above and attempt to open the same com port with hyperterminal. With the option set and the VI Paused at the break hypertermnal will report the resource is in use. Aborting the vi releases the resouce just as if the VISA close executed. Uncheck the option and the behavior reverts back to holding the resource open untill the close function does run.
08-04-2010 11:22 AM
Thanks all. Why is the automatic close option a pita if I use comm a lot?
08-04-2010 11:35 AM
With the option OFF the sessions remain valid and you can run sub-vis that use the sessions without needing to add a open session in the sub-vi. Often this is an aid to debugging GPIB commands and such nasty things as writing drivers for equipment with user manuals that have ambigeous command syntax. Knowing the behavior of this option (like 95% of your ini settings) can save some valuable time.
08-04-2010 12:09 PM
That's not much of problem as long as you are using a version of NI-VISA from the past several years. The VISA Open is now optional. If a session is not open, one will be automatically created by any VISA function. I think that is why the open and close functions are on the Advanced palette.
08-04-2010 12:20 PM
@Dennis Knutson wrote:
That's not much of problem as long as you are using a version of NI-VISA from the past several years. The VISA Open is now optional. If a session is not open, one will be automatically created by any VISA function. I think that is why the open and close functions are on the Advanced palette.
Yeah but, I do sometimes work with 6.1
08-04-2010 12:24 PM
Sorry. That's cruel and unusual punishment.
08-04-2010 01:04 PM
We didn't think so when "6i" came out!