This is the thing so far: I cant get ctrol_transfer to work in anyway. It will always give an error. Calling it even without payload:
# find our device dev = usb.core.find(idVendor=TI_VENDOR_ID, idProduct=TI_3410_PRODUCT_ID) dev.set_configuration() # was it found? if dev is None: raise ValueError('Device not found') print dev print dev.bNumConfigurations interface = dev.get_interface_altsetting() --- here try detach --- # Setting configuration if dev.bNumConfigurations == 1: raise "ERROR: The firmware was not yet uploaded" elif dev.get_active_configuration().bConfigurationValue == 1: dev.set_configuration(TI_ACTIVE_CONFIG) else: print "Configuration already set in ", TI_ACTIVE_CONFIG requesttype = (usb.util.CTRL_TYPE_VENDOR | usb.util.CTRL_RECIPIENT_DEVICE | usb.util.CTRL_OUT) command = 1 #USBCTRL_WRITE_DATA value = 2 moduleid = 3 #USBCTRL_RAM_PORT msg = None print requesttype, command, value, moduleid, msg, 0 print dev.ctrl_transfer(requesttype,command, value, moduleid, None) msg = [48, 1, 1, 0, 0, 255, 164, 48, 255] print dev.ctrl_transfer(requesttype,command, value, moduleid, msg) I readed all of the pertinent source code of pyusb until the call to libusb, and I myself cant find what the problem is. The "msg" can be any interable type and is converted then with buff=array.array('B', data) addr, length = buff.buffer_info() length *= buff.itemsize print bmRequestType, bRequest, wValue, wIndex, cast(addr,POINTER(c_ubyte)), length, timeout ret = _check(_lib.libusb_control_transfer(dev_handle, bmRequestType, bRequest, wValue, wIndex, cast(addr, POINTER(c_ubyte)), length, timeout)) and is HERE where it fails. The definition of this function is here: http://libusb.sourceforge.net/api-1.0/group__syncio.html#gadb11f7a761bd12fc77a07f4568d56f38 The device IS responding because i do can set the configuration, and if the driver is not detached, it says "Device busy". How is it, that any control transfer works? It sound like a problem setting the correct data types between pyusb and libusb. I need an example on pyusb to do a working control transfer, to something that is known to work. Any way, the only and only LIBUSB_ERROR_IO raised by ctrl_transfer is on the same libusb library which calls usbfs on an implementation in the file linux_usbfs.c function submit_control_transfer with the next lines of code: http://svn.dd-wrt.com:8000/dd-wrt/browser/src/router/usb_modeswitch/libusb/libusb/os/linux_usbfs.c?rev=12369#L1518 There isnt any other reference to LIBUSB_ERROR_IO. Cheers. Diego 2010/6/24 Xiaofan Chen <xiaof...@gmail.com>: > On Thu, Jun 24, 2010 at 12:25 PM, Diego Jacobi <jacobidi...@gmail.com> wrote: >> Can somebody give a better example on how to call ctrl_transfer with a >> data payload ? > > It all depends on the device. > A C example here (sorry right now I have no pyusb example). > http://www.microchip.com/forums/fb.ashx?m=475777 > > To use libusb/pyusb, you have to know the protocol of the device. > Since you do not have access to the device internals, then the way > to do it is using reverse-engineering: eg: to use usb sniffer under > Windows. > > > -- > Xiaofan http://mcuee.blogspot.com > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users > ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users