2013/10/2 vvyogi . <vvy...@gmail.com>: > This is the complete log > >> Traceback (most recent call last): >> File "myu.py", line 21, in <module> >> dev.set_configuration() >> File "C:\Python27\lib\site-packages\usb\core.py", line 547, in >> set_configuration >> self._ctx.managed_set_configuration(self, configuration) >> File "C:\Python27\lib\site-packages\usb\core.py", line 92, in >> managed_set_configuration >> self.backend.set_configuration(self.handle, cfg.bConfigurationValue) >> File "C:\Python27\lib\site-packages\usb\backend\libusb10.py", line 503, >> in set_configuration >> _check(_lib.libusb_set_configuration(dev_handle, config_value)) >> File "C:\Python27\lib\site-packages\usb\backend\libusb10.py", line 403, >> in _check >> raise USBError(_str_error[ret], ret, _libusb_errno[ret]) >> usb.core.USBError: [Errno 2] Entity not found >
set_configuration is faling here, but this you probably already know... > > My code is as follows > >> import usb.core >> import usb.util >> import sys >> # find our device >> dev = usb.core.find(idVendor=5824, idProduct=1503) >> # was it found? >> if dev is None: >> raise ValueError('Device not found') >> >> print "VUSB Device Found" ## THE DEVICE GETS DETECTED >> >> >> >> print dev.bNumConfigurations >> print dev.bDeviceClass >> print dev.bLength >> >> # set the active configuration. With no arguments, the first >> # configuration will be the active one >> >> dev.set_configuration() >> dev.ret = dev.ctrl_transfer(0xC0, 0x00, 0, 0, 128) > Your code looks fine, at least until the set_configuration call. > > > My OS is Windows 7 32-bit, using python 2.7.3 and pyusb-1.0.0a2 > In above code the Device gets detected, but fails at the point where 'set > configuration' happens.. > What about latest pyusb code from github? > I tried equivalent code in C#(based on libUsbDotNet, which is also a wrapper > on libusb), and it worked fine. > Here is the c# code snippet for reference. >> >> MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder); >> // If the device is open and ready >> if (MyUsbDevice == null) throw new Exception("Device Not >> Found."); >> // If this is a "whole" usb device (libusb-win32, linux >> libusb) >> // it will have an IUsbDevice interface. If not (WinUSB) >> the >> // variable will be null indicating this is an interface >> of a >> // device. >> IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; >> >> if (!ReferenceEquals(wholeUsbDevice, null)) >> { >> // This is a "whole" USB device. Before it can be >> used, >> // the desired configuration and interface must be >> selected. >> // Select config #1 >> wholeUsbDevice.SetConfiguration(1); >> // Claim interface #0. >> wholeUsbDevice.ClaimInterface(0); >> Console.WriteLine("\r\nMAc MAc!\r\n"); >> } >> >> UsbSetupPacket setup = new UsbSetupPacket(0xC0, 0x01, 0, >> 0, 128); >> bool result = MyUsbDevice.ControlTransfer(ref setup, >> buffer, 128, out ltt); >> Console.WriteLine("Result = {0}", result); > > > > The only difference that I could find is that the c# code is doing > 'CLAIM_INTERFACE', but that is done automatically by pyUsb. > Other thing that comes to my mind is the USB_BACKEND being in use by pyUsb. > I have not installed winUSB or OpenUSB. How do I check my currently active > USB backend. > what Is wrong with my python code? > Your PyUSB backend is libusb 1.0, libusbdotnet can use libusb-win32, WinUSB or libusb 1.0. AFAIK, libusb 1.0 production code can only use WinUSB right now. Do you know what backend is being used by libusbdotnet? Let's try to see what PyUSB is doing. Please, define the environment variable PYUSB_DEBUG_LEVEL=debug (for a2 release) or PYUSB_DEBUG=debug (for github HEAD), run your program again and post here the logs. -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users