Hello...
I try to do some async transfer. The program bellow actualy 'near' work.
It setup 10 transfers and should print the received bytes in callback.
The problem is that callback is not done at receive complete!
In example below I expect callback while sleep comand is executed but 
instead got all callbacks when I close device...
I know that USBPoller/USBPollerThread has something to do with my 
problem but don't know how to use it.

Here is my test program:
#***************************************************************
import usb1,time

def openUsb(vid,pid,name):
     context = usb1.USBContext()
     for dev in context.getDeviceList(skip_on_error=True):
         if (dev.getVendorID()==vid) & (dev.getProductID()==pid):
             if dev.getProduct()==name:
                 return dev.open()

USBdev=openUsb(0x16d0,0x06ad,'Q_ANALISER')
if not USBdev:
     print "Device not found"
     exit(0)

def callback(transfer):
     print "Just received %4.0f Bytes" % transfer.getActualLength()

transfer=[]
for i in range(10):
     transfer.append(USBdev.getTransfer())
     transfer[-1].setControl(160, 3, 0, 0, 4096, callback, None, 1000)
     transfer[-1].submit()


time.sleep(1)
print "sleep 1 done."
time.sleep(1)
print "sleep 2 done."

USBdev.close()
print "Device closed."
#***************************************************************


And this is output. (received length is as expected 1'st frame is 1 as 
this indicated overrun in my device and other's are actual packets)

sleep 1 done.
sleep 2 done.
Just received    1 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Just received 2870 Bytes
Device closed.


------------------
(program exited with code: 0)
Press return to continue


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to