02-23-2016 12:59 AM
I'm trying to figure out a way to stop / interrupt as fast as possible a while loop containing a VISA read function call.
The visa source is set with a timeout of 1ms, however it seems that it actually takes much longer when the operation is timing out.
My loop does not only contain this visa read call, but it's pretty clear that regardless of how badly wired the rest of the loop is, the bottleneck is clearly the read call (replacing it with a wait function of 1ms is definitely faster).
The elapsed time can up to 29ms (on my local) configuration when using the read call and about 1-2ms when using a dummy wait.
I am aware of the underlying operations, the serial port is leveraged as a file through the OS sometimes it may be suject to locks and can be slower than the timeout indicated in the configuration but seems it's still kinda too much compared to what I get with the wait call.
Any idea to improve that?
Thanks
02-23-2016 07:40 AM - edited 02-23-2016 07:40 AM
Why do you even want to do this? This seems more like a poor plan of attack than an issue with the VISA Read.
02-23-2016 01:32 PM
You should replace the sequence structure with a simple state machine. That is much easier to interrupt.
But...., the key to your question may be in part of the code which you did not include. What is the baud setting? How many bytes are in each message? Does each message contain a termination character? Is the port configured to use the termination character?
Lynn
02-23-2016 01:43 PM
I'd still like to know why you want this unusual behavior. Maybe we can suggest something better.