LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt Visa Wait on Event

Solved!
Go to solution

I'm using VISA Wait on Event, serial character, to wait for serial data to arrive. The data arrives once per minute. I have the timeout set for 70 seconds so that the program won't do any reads until the one minute data arrives. If I want to stop the program I have to wait for the message to arrive because the program is "stalled " at the wait on event function. How can I interrupt the wait on event?? The problem I see is that while it's waiting nothing is read. So no booleans are read. I have a feeling I might have to accept this flaw in the event function. All advice is appreciated. Thanks.

 

ssmith

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

I think it's not possible to break waiting on event. This was my problem too. If you will use another library ( lvserial.dll ), there it's possible by using Flush Buffer funktion, but not in VISA.

You can set your Timeout value e.g. to 1 second, and if timeout happens do nothing (switch case).

0 Kudos
Message 2 of 9
(4,476 Views)
Solution
Accepted by topic author ssmith490D
Instead of using the event, you could use the VISA Bytes at Serial Port. As long as you put a reasonable wait time in your loop (i.e. 100-250 msec), you can stop the program quickly. You could also change the event timeout to something much smaller and ignore the timeout error you would get. Use one of the timing functions (i.e. Tick Count) to determine how often you get data and set an error if the instrument stops sending.
Message 3 of 9
(4,463 Views)

The best choice is:

 

if you use ASCII protokoll with Termination Carachter(s)

if you use binary protokoll, than you have to know how many bytes to read (package length) and connect this to bytes to read input of the VISA read VI.

0 Kudos
Message 4 of 9
(4,457 Views)
How do you use the timeout error from the wait in event to select a case?
0 Kudos
Message 5 of 9
(4,442 Views)
Unbundle the error code and wire it to a case statement. If you want, the error cluster can be wired directly to the case selector and then you can undbundle the error code inside the case statement.
Message 6 of 9
(4,439 Views)
Thanks Dennis
0 Kudos
Message 7 of 9
(4,435 Views)

I personnaly never use the solution from Dennis. So I find this solution not good (or only partitionally good). It may work good for a generally terminal programm (to show received data to user), but if you want to work with a device and have to react as soon as possible and right, the suggestion has some disadvantages.

 

Eugen

0 Kudos
Message 8 of 9
(4,395 Views)

Eugen--

       In this case it's fine. I'm simply monitoring a com port and when data comes in I write it to a file. If the message is not the expected length I write it to an error file. No interaction required. Thanks.

 

ssmith

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