LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

initialize com port not closed properly

If a power lose (or abort execution) results in a com port resource not being closed properly, what is the programmatic fix for the com port?
0 Kudos
Message 1 of 3
(2,811 Views)

As of that I know, if you do not stop and remove your program from memory (stopping all) you should always clear the reference to the com port.Always code that way. btw, exiting an exe closes the ref. (but you should still code the closure) (in windows). In dev. mode, do not abort execution, it does not remove the ref.I think its not possible to close a type of com reference under "abort execution", since youve lost your ref ID next time you want to run your app in dev. mode. I have not experienced this with VISA-COM, but with CAN-bus I have.Perhaps there is a programmatic fix, but still I think it is not the correct way to work.

 

but.. I did not really understand your powerloss.. than your computer&com port should go down too..?

 

References should always be stopped and closed. Some ref. types (f.ex. datasocket) if not closed and instead new ref is created over and over (and works), youll get a small memory leak that gets big after a while.

0 Kudos
Message 2 of 3
(2,801 Views)
Well, if the pc loses power the VISA reference is closed and if you check 'Automatically close VISA sessions' in Options>Environment, the reference is also closed when the VI stops. Typically, the only problem with an open reference is that another program cannot access the port. Unless you have specifically selected 'duplicate session' with the VISA Open session, you will just reuse an existing reference if you call VISA Open without doing a close.
0 Kudos
Message 3 of 3
(2,797 Views)