Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop ibwait quickly. (Can't set timeout to be too short)

What I want to do:
Send a command to a GPIB instrument to trigger a time-consuming task, then I should be able to stop the time-consuming task anytime before it finishes normally.
 
What I have done:
Call these functions in one thread,

ibtmo(ud, 16)   #set timeout to 300s
ibwrta(ud, "...", ...)  #write the command asynchronously
ibwait(ud, TIMO | RQS)  #wait for RQS or timeout
 
When I try to cancel the time-consuming task, I call these functions in another thread,
ibstop(ud)
ibwrt(ud, "...", ...)  #write instrument specific cancel command
 
I've also tried to use ibonl,
ibonl(ud, 1)   #reset the interface
ibwrt(ud, "...", ...)  #write instrument specific cancel command
 
Problem:
both ibstop and ibonl take too long to return, they seems to wait the time-consuming task to finish and then return, which isn't what I want to do. Did I do the right thing? Where is the problem? Any help is greatly appreciated.
 
PS:
I wrote the program in C
GPIB driver version is 2.4
0 Kudos
Message 1 of 2
(3,124 Views)
Why don't you use either:
1) ibwait (0) in a loop and check the response, or
2) ibnotify to notify on the condition. This can be cancelled if necessary.
0 Kudos
Message 2 of 2
(3,114 Views)