On Mon, Nov 9, 2015 at 8:05 PM, Jordi M <jmer3...@gmail.com> wrote: > Hi all, > > I'm trying to connect an ST Micrielectronics board that runs ChiBios OS > to a PC either running Ubunto or windows using PyUsb (I have the same > problem in both Os) > > The problem is that it works well the first time but when I re-execute > the sricpt it shows this error and I have to unplug and replug again a > couple of times the usb cable until it works again. > > The error message is : > > [Errno None] libusb0-dll:err [_usb_reap_async] reaping request failed, > win error: A device attached to the system is not functioning. > > Any aidea what is happenning? > Maybe I need to close the device before exiting the script or similar?
Usually this kind of thing means device FW bug. You can try to reset the device before exiting or things like that. Ref: https://github.com/libusb/libusb/issues/111 >From the above, it seems that ST FW library has some bugs. You can also try to see if this is a libusb-win32 problem or not. pyusb supports either libusb-win32 or libusb Windows (libusb-1.0) under Windows. You can switch the device driver to WinUSB and use libusb-1.0 backend of pyusb to see if that helps. > My code is: > > > # find our device > dev = usb.core.find(idVendor=0x0483, idProduct=0xFEDC) > > # was it found? > if dev is None: > raise ValueError('Device not found') > > # set the active configuration. With no arguments, the first > # configuration will be the active one > #dev.set_configuration() What if you try to uncomment this line? > # get an endpoint instance > cfg = dev.get_active_configuration() > intf = cfg[(0, 0)] > > ep = usb.util.find_descriptor( > intf, > # match the first OUT endpoint > custom_match=\ > lambda e: \ > usb.util.endpoint_direction(e.bEndpointAddress) == \ > usb.util.ENDPOINT_OUT) > > epr = usb.util.find_descriptor( > intf, > # match the first IN endpoint > custom_match=\ > lambda e: \ > usb.util.endpoint_direction(e.bEndpointAddress) == \ > usb.util.ENDPOINT_IN) > > assert ep is not None > assert epr is not None > > ####Some code###### > > usb.util.dispose_resources(dev) > print "END" -- Xiaofan ------------------------------------------------------------------------------ Presto, an open source distributed SQL query engine for big data, initially developed by Facebook, enables you to easily query your data on Hadoop in a more interactive manner. Teradata is also now providing full enterprise support for Presto. Download a free open source copy now. http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140 _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users