LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Com port issue when program restart on incorrect exit

I have a labview VI in which there is data coming from COM port, and intially user is asked to set com port.

There is EXIT button on the VI, which when pressed, safely exits the code, and close the com port. If user do this then when next time VI start again then no issues come.

 

Issue arises, if instead of safe EXIT , user user "Cross Close button" on top right of all window dialogs or end task from task manager, then what happend it COM port dont get freed, I suppose.

On next rerun of VI, even if user is able to select the COM port but no data is received, unless VI is closed, usb port is disconnected and connected again.

 

Whats the solution for this.

0 Kudos
Message 1 of 12
(2,459 Views)

I use an Event Structure to handle the closing of the VI panel (Panel Close filter event).  I use the filter event so I can discard the closing, perform all of the clean up, and then close the panel myself (if in an executable).


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 12
(2,426 Views)

Hi,

Perform the below mentioned steps.

  1. Select Tools » Options to display the Options dialog box. 
  2. Select Environment from the Category list.
  3. Check the Automatically Close VISA Sessions checkbox
  4. Select OK
Message 3 of 12
(2,423 Views)

@crossrulz thanks for your reply.

Can you show one example or sample?

 

0 Kudos
Message 4 of 12
(2,416 Views)

@Vindhyachal.Takniki wrote:

@crossrulz thanks for your reply.

Can you show one example or sample?


Slight editing from a VI I showed at VIWeek:


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 5 of 12
(2,412 Views)

kartiknattar@ospl.in wrote:

Hi,

Perform the below mentioned steps.

  1. Select Tools » Options to display the Options dialog box. 
  2. Select Environment from the Category list.
  3. Check the Automatically Close VISA Sessions checkbox
  4. Select OK

While this will probably solve the problem the OP is having. 

 

The automatically closing VISA sessions option is NOT a replacement for proper programming!

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 12
(2,396 Views)

@RTSLVU wrote:

kartiknattar@ospl.in wrote:

Hi,

Perform the below mentioned steps.

  1. Select Tools » Options to display the Options dialog box. 
  2. Select Environment from the Category list.
  3. Check the Automatically Close VISA Sessions checkbox
  4. Select OK

While this will probably solve the problem the OP is having. 

 

The automatically closing VISA sessions option is NOT a replacement for proper programming!


This may fix the immediate problem, but not the ultimate problem. I generally don't even include a STOP button on my front panels any more (at least with the Exit the program context - I might have a button to stop a particular task). In my opinion the introduction of the Event Structure and the Panel Close? filter event may very well be the greatest innovation in LabVIEW since it's first introduction (and that includes the switch from Traditional DAQ to DAQmx). No more polling.Better control of the program.

0 Kudos
Message 7 of 12
(2,384 Views)

@RTSLVU wrote:

kartiknattar@ospl.in wrote:

Hi,

Perform the below mentioned steps.

  1. Select Tools » Options to display the Options dialog box. 
  2. Select Environment from the Category list.
  3. Check the Automatically Close VISA Sessions checkbox
  4. Select OK

While this will probably solve the problem the OP is having. 

 

The automatically closing VISA sessions option is NOT a replacement for proper programming!


While I agree that shutting down properly should be handled (ie handling the panel close), it still does not handle the "end task from task manager" case. Does LabVIEW release the handle after exiting out of LabVIEW?

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 8 of 12
(2,379 Views)

@Frozen wrote:

@RTSLVU wrote:

kartiknattar@ospl.in wrote:

Hi,

Perform the below mentioned steps.

  1. Select Tools » Options to display the Options dialog box. 
  2. Select Environment from the Category list.
  3. Check the Automatically Close VISA Sessions checkbox
  4. Select OK

While this will probably solve the problem the OP is having. 

 

The automatically closing VISA sessions option is NOT a replacement for proper programming!


While I agree that shutting down properly should be handled (ie handling the panel close), it still does not handle the "end task from task manager" case. Does LabVIEW release the handle after exiting out of LabVIEW?


I have found that the development environment indeed does. But if a compiled program is aborted through Ctl+Alt+Del and you kill the process with Task Manager there is no guarantee even with "Automatically Close VISA sessions" enabled. 

 

As the program has to properly exit for that to occur automagically...

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 12
(2,373 Views)

could you please share your LabVIEW file

0 Kudos
Message 10 of 12
(1,870 Views)