LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Wait On Event Crashes LabVIEW

While "VISA Wait On Event" is pending on an event, and in another thread the "VISA resource name" input to "VISA Wait On Event" is closed using "VISA Close" vi LabVIEW crashes.

 

I had a need to programmatically cause "VISA Wait On Event" to unblock so the LabVIEW program it is running in can be closed, or the "VISA resource name" originally input to "VISA Wait On Event" can be changed. I expected that executing "VISA Close" in another thread would cause "VISA Wait On Event" to unblock with an error. Instead LabVIEW crashes.

0 Kudos
Message 1 of 8
(3,543 Views)

Artst,

 

Can you post a screenshot of your code to further clarify?  

 

It sounds like you are trying to stop the VIs by clearing the reference while it is still in use which will lead to a crash.  There is not a way to "unblock" a VI once it is running.  Can you specify a timeout instead?

 

 

James K.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 8
(3,511 Views)

Regular time outs will require poling in a spinning loop I was hoping to avoid. This wastes the processor's time.


I attempted to create a minimized VI to demonstrate this problem. The trouble with it is that it did not crash. Executing "VISA close" caused the "VISA Wait on Event" vi in the other thread to unblock with a timeout error as I originally expected it do and needed it to do. I tried to develop that example VI more to make its context more like the VI I have this problem with, but the crash could not be duplicated with it. I ran out of time trying to find out what is different. So I have attached the entire VI I have this problem with. The crash is triggered when the "VISA resource name" control field on the front panel is used to select a COM port. The selection does not have to be a different from one already selected. This VI was created in LabVIEW 2012sp1.


The VI to run in the attached is located at: "\MOSA 6\MOSA 6 Firmware Development.vi"

 

0 Kudos
Message 3 of 8
(3,494 Views)

What error are you receiving when LabVIEW crashes? From your previous post, it sounds almost as if the error is more to do with something in your event structure then something specifically related to the VISA commands.  

James K.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 8
(3,478 Views)

There is definitely a problem with VISA wait on event... VISA Enable Event dumps LabVIEW memory onto serial port

It's about time somebody at NI tried to fix it.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 5 of 8
(3,410 Views)

Artst,

 

Could you give an explanation of how I might reproduce the error with the code you posted? Also, along with James, I'm curious as to what error is thrown when LabVIEW crashes. 

 

Troy,

 

I agree that this does seem to be odd behavior of the VISA Wait On Event function. Did you start with any examples when trying to use VISA events? I found a PDF that seems like it would be useful as a starting point. I've attached a link to it below.

 

http://www.ni.com/support/visa/vevents.pdf

Robert B
RF Product Support Engineer
National Instruments
0 Kudos
Message 6 of 8
(3,367 Views)

USBarnes wrote: Did you start with any examples when trying to use VISA events?

No, but the "Port B.vi" example I posted in the other thread is quite similar to VISA wait on event example that ships with LabVIEW.


I found a PDF that seems like it would be useful as a starting point. I've attached a link to it below.

The pdf you suggest uses GPIB and was written 15 years ago. Both problems reported by Artst and myself are using serial COM ports.

The sub-palette, controls and refnums it says to use don't even seem to exist any more in LabVIEW 2011/12.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 7 of 8
(3,360 Views)

@James-K wrote:

Artst,

 

Can you post a screenshot of your code to further clarify?  

 

It sounds like you are trying to stop the VIs by clearing the reference while it is still in use which will lead to a crash.  There is not a way to "unblock" a VI once it is running.  Can you specify a timeout instead?

 

 


Well, I think this is not giving enough credit to the actual problem. One common VISA programming paradigme in the standard C API is to actually let a VISA Read (and of course a VISA Wait on Event) to terminate with an error by issuing the viTerminate() function, which I believe should be possible to get optionally be called by VISA Close too. Unfortunately there is no direct access to any VISA Terminate function in the LabVIEW palettes, but I have in the past created a small VI which calls the underlaying VISA API directly to abort any stuck operations on a session. Possibly this VI could solve the problem, making the VISA Wait On Event return before the VISA Close pulls its session under its feet.

 

PS: Why can't I upload the VI directly to the board? Is it because it is in LabVIEW 7.1 format??

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 8 of 8
(3,349 Views)