From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read timeout problem again - caused by UUT power off

I have a subVI with state machine structure to decode data streams from serial port.

State1 is to check the Start of Frame

State2 is to read the payload

...

StateN is to check the checksum

 

Here is the problem:

Power down the UUTarget while the VI is still running, and I gets the VISA Read Timeout Error because there is no data in the serial port from target anymore.

Next time when you UUT is powered up again, I still get the VISA read Timeout Error and nothing works again.

 

Is there any suggestion how to handle this if I want to keep the VI running all the time?

 

I tried to use Elapsed Time VI to calculate certain amount of time and stop the VI by exiting the loop, but have problem understanding Elapsed Time VI and worried about its execution time.

 

Thank you for any advice.

0 Kudos
Message 1 of 7
(3,128 Views)

MileP,

 

Have you tried the VISA Flus I/O Buffer.vi, or the VISA Clear.vi? These may free up the buffer for new data.

National Instruments
0 Kudos
Message 2 of 7
(3,103 Views)

Have you cleared the error from your state machine?

I assume your error cluster is passed through a shift register.

Just one of those "flat forehead" checks.

0 Kudos
Message 3 of 7
(3,100 Views)

Thank you all!

 

I did clear the error when the elapsed time reaches the expected time. The problem is, I wired the Error Out of VISA Read to Error In of "Elapsed Time" VI, so the "Elapsed Time" VI doesn't function at all when there is VISA Read timeout error. It's interesting. I thought the errors are sort of independent here.

 

0 Kudos
Message 4 of 7
(3,068 Views)

The rule for handling errors is easy

If you have to do some IO in a vi that gets an error in, don't do the IO but pass the error.

Even better don't do anything except passing the error.

Except for closing a connection or file etc. Then close the file or connection and also pass the error!.

greetings from the Netherlands
0 Kudos
Message 5 of 7
(3,061 Views)

Thank you, Albert. But I think Elapsed Time VI should always work even when there is input error.

0 Kudos
Message 6 of 7
(3,028 Views)

I would expect also but opening it and going into subElapsedTime I saw that in case of an error NO code is executed at all.

Seems the wrong way to handle an error.

It is not allowed to change the error but is anyhow except showing nothing also not touching the error.

 

SO it simply is a choice (and I think a wrong choice) of the developer of the Elapsed time VI

greetings from the Netherlands
0 Kudos
Message 7 of 7
(3,010 Views)