-------- Original-Nachricht --------
> Datum: Mon, 12 Nov 2012 08:43:33 -0200
> Von: Wander Lairson Costa <wander.lair...@gmail.com>
> An: pyusb-users@lists.sourceforge.net
> Betreff: Re: [pyusb-users] Devices disconnects after several request

> 2012/11/12 Stefano Di Martino <stefan...@gmx.net>:
> > Hi,
> > I tested it under Linux, but there was no problem. But I tested it on an
> another Computer with Python 2.7 instead of 2.5.
> > The other thing is, I can't reproduce this problem, with C.
> >
> > I made a simple stress test with python:
> >
> > This works:
> >
> > for i in range(100):
> >     usb.core.find(find_all=True)
> >
> > This don't work!
> >
> > for i in range(100):
> >     device_list = usb.core.find(find_all=True)
> >
> > Two lines of code (besides the import), nothing more...
> > The error message:
> >
> > "usb.core.USBError: [Errno 19] No such device (it may have been
> disconnected)"
> >
> > Where it happens:
> >
> > class _DevIterator(object):
> >     def __init__(self):
> >         self.dev_list = POINTER(c_void_p)()
> >         self.num_devs = _check(_lib.libusb_get_device_list(
> >                                     None,
> >                                     byref(self.dev_list))
> >                                 ).value # Here!
> >
> >
> > def _check(retval):
> >     if isinstance(retval, int):
> >         retval = c_int(retval)
> >     if isinstance(retval, c_int):
> >         if retval.value < 0:
> >            from usb.core import USBError
> >            ret = retval.value
> >            raise USBError(_str_error[ret], ret, _libusb_errno[ret]) #
> Here the Exception rises.
> >     return retval
> >
> >
> > My simple C code:
> >
> > for(i = 0; i < 100; i++) {
> >     cnt = libusb_get_device_list(NULL, &devs);
> >     if (cnt < 0)
> >         return (int) cnt;
> >     if (i < 99)
> >         libusb_free_device_list(devs, 1);
> > }
> >
> 
> What happens if you don't call libusb_free_device_list?

It crashes. Enable debug won't help, because it crashes before it can print 
debug messages.
By the way: I've found out, that it only crashes, when a Cherry keyboard is 
attached:

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x08 (8)
idVendor:           0x046A (Cherry GMBH)
idProduct:          0x0011
bcdDevice:          0x0100
iManufacturer:        0x00
iProduct:             0x00
iSerialNumber:        0x00
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:      Low
Device Address:       0x01
Open Pipes:              1

Endpoint Descriptor:
bEndpointAddress:     0x81
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x0A

Best regards
Stefano

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to