On Mon, Oct 1, 2012 at 9:27 AM, Stefano Di Martino wrote: > Hi everyone, > I'm testing PyUSB right now and tried this example: > >>>> msg = 'test' >>>> assert dev.ctrl_transfer(0x40, CTRL_LOOPBACK_WRITE, 0, 0, msg) == len(msg) >>>> ret = dev.ctrl_transfer(0x40, CTRL_LOOPBACK_READ, 0, 0, len(msg)) >>>> sret = ''.join([chr(x) for x in ret]) >>>> assert sret == msg > > The problem is, that the variables CTRL_LOOPBACK_WRITE and CTRL_LOOPBACK_READ > aren't recognized. I have imported usb.core and usb.util, but it doesn't work. > I looked for these variables in the PyUSB source code with file search, but I > didn't find them. > I'm using the latest 1.0.0a3 pyUSB and libusb-win32. > > Thanks in advance for any suggestion. > Stefano >
Hi Stefano, I believe this example is taken from http://pyusb.sourceforge.net/docs/1.0/tutorial.html The accompanying text says: "In this example, it is assumed that our device implements two custom control requests that act as a loopback pipe. What you write with the CTRL_LOOPBACK_WRITE message, you can read with the CTRL_LOOPBACK_READ message." So unless you have a device which implements these custom control requests, the example code will not work. And if you have such a device, it is up to the device what the values of CTRL_LOOPBACK_WRITE and CTRL_LOOPBACK_READ should be. Regards, Tormod ------------------------------------------------------------------------------ Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users