LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Visa/RS232] reading data stream of uncertain length

Solved!
Go to solution

Hallo,

 

I try to find a solution for the following problem.

 

The device sends me after starting the measurement, the acquired data points in a continuous stream with a certain rate. Usually I'm just using a loop with the "Visa Read.vi" read the data point one after the other, which works fine as long as I know the exact number of data points.

 

The problem is that the device has mode for fast measurements where I don't know the number of data points, therefore I'm looking for an elegant solution to close the loop, when the stream has finished.

 

Does anyone has an idea?

0 Kudos
Message 1 of 13
(4,762 Views)

Hi GMAch,

 

an elegant solution to close the loop, when the stream has finished.

Usually you can use the TimeOut error to end your reading loop…

Elegant because it's easy to implement! 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(4,756 Views)

If there is no measurement stop marker, the only way to go is managing a proper timeout.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 13
(4,755 Views)

Does anyone has en example how to realize such a time out properly?

Message 4 of 13
(4,743 Views)
Solution
Accepted by topic author GMAch

VISA Configure Serial Port features a timeout input (in ms, the leftmost of the top border); its default value is 10000. Another possibility is to use the VISA Set Timeout function in the Advanced VISA palette. The timeout value should be chosen on the basis of the device output frequency.

When the timeout has expired, VISA Read terminates with error code -1073807339.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 13
(4,729 Views)

Does that properly close the loop?

 

I would prefer a solution where I get a condition that I can use to "push the stop button"  of the while loop.

0 Kudos
Message 6 of 13
(4,722 Views)

This is equally ok. You will need to setup a timeout in any case, to limit the time VISA Read is stuck.

Just let the user know that no more data are coming. For example, you may show on the FP a counter of the received data blocks, or a LED that turns on when a timeout occurs.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 13
(4,719 Views)

OK thanks.

0 Kudos
Message 8 of 13
(4,712 Views)

What instrument are you using?  More specifically, what is the format of the data being sent to you?  There might be better ways than relying on a timeout, but it depends on the message data structure.


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 9 of 13
(4,697 Views)

The device just sends for each measurement a string that is ended by a carriage return, with a rate that I can set.

0 Kudos
Message 10 of 13
(4,692 Views)