08-31-2012 10:22 AM
I am wondering if it is possible to manually terminate a USB read. The reason why is because I have an instrument that can wait for an external trigger before sending data. Problem is that sometimes no trigger signal comes and the user needs to be able to simply abort the attempt to read. I could set a timeout but the amount of time before a signal is wide open and a huge timeout will be as bad and none at all. It occurred to me I could do a loop with a sorter timeout and if the user does not press the cancel button just keep attempting to read from the device.
Is there any way to manually abort the read operation?
James
09-04-2012 06:03 PM
You could try to use an event structure that stops the task when the user presses a button. That way if the event does not register it will continue to wait for the trigger and collect data when it is triggered. If it does register, it will stop the task and end the program.
09-04-2012 11:42 PM - edited 09-04-2012 11:43 PM
You cannot abort a read once you start it. Your idea of using a shorter timeout and looping is basically the method you would use.
You may want to kudo this idea.
09-05-2012 02:09 AM - edited 09-05-2012 02:11 AM
@Mark_Yedinak wrote:
You cannot abort a read once you start it. Your idea of using a shorter timeout and looping is basically the method you would use.
Not with native LabVIEW nodes so far. But this should work! This method works because LabVIEW really makes use of the asynchronous VISA API under the hood. If it wouldn't nobody could talk with more than one device at the same time, a pretty though limitation for a multi device test system.
With that said, I'm pretty sure there is a reason this method is not really available in LabVIEW. It may work unreliable either in combination with the rest of what LabVIEW is doing when accessing VISA or just in general. So make use of it with care.
09-05-2012 09:23 AM
Ok. Thank you all for your input. I will avoid the dll calls if I can, and just use the timeout in a loop, but it is nice to keep them in my back pocket.
09-05-2012 09:24 AM
@rolfk wrote:
@Mark_Yedinak wrote:
You cannot abort a read once you start it. Your idea of using a shorter timeout and looping is basically the method you would use.
Not with native LabVIEW nodes so far. But this should work! This method works because LabVIEW really makes use of the asynchronous VISA API under the hood. If it wouldn't nobody could talk with more than one device at the same time, a pretty though limitation for a multi device test system.
With that said, I'm pretty sure there is a reason this method is not really available in LabVIEW. It may work unreliable either in combination with the rest of what LabVIEW is doing when accessing VISA or just in general. So make use of it with care.
Aborts always have the possibility to be dangerous. Pulling the plug on anything can leave you in an unknown state. However, it is useful to have the capability.
I'll have to play with your code a bit to see how it works.
09-12-2012 10:55 AM
I'm very interested in the Abort VIs - I have a project where intermittently the system will hang in a VISA call with no obvious rhyme or reason. I'm curious if this would be able to recover the situation.
09-12-2012 11:20 AM
asbo wrote
09-12-2012 11:23 AM
The VI's are attached to my previous post.
And elegant in instrument control is whatever works reliable. Not sure the Abort VISA option satisfies that. It worked for me, but YMMV.