12-20-2017 04:20 AM
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?
Solved! Go to Solution.
12-20-2017 04:32 AM
12-20-2017 04:32 AM
If there is no measurement stop marker, the only way to go is managing a proper timeout.
12-20-2017 05:04 AM
Does anyone has en example how to realize such a time out properly?
12-20-2017 05:17 AM
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.
12-20-2017 05:29 AM
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.
12-20-2017 05:39 AM
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.
12-20-2017 05:51 AM
OK thanks.
12-20-2017 06:24 AM
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.
12-20-2017 06:42 AM
The device just sends for each measurement a string that is ended by a carriage return, with a rate that I can set.