LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is is possible to abort USB read without a timeout

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

0 Kudos
Message 1 of 9
(1,313 Views)

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.

Cameron T
Applications Engineer
National Instruments
0 Kudos
Message 2 of 9
(1,279 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 9
(1,270 Views)
Highlighted

@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.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 4 of 9
(1,261 Views)

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.

0 Kudos
Message 5 of 9
(1,245 Views)

@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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 9
(1,244 Views)

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.

0 Kudos
Message 7 of 9
(1,197 Views)

asbo wrote

 

"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."
 
 
I am also very interested in this topic. Also would like to know if this could also apply to any VISA read  such as a Serial read.
I currently use the short timeout loop approach with serial VISA to increase reliability and it works fine, but I've always wanted to see a more elegant alternative if one exists.

 

0 Kudos
Message 8 of 9
(1,185 Views)

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.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 9 of 9
(1,181 Views)