Thanks, but i am sadly confirming that this is not the error this time. I have correctly detached it with:
interface = dev.get_interface_altsetting() dev.detach_kernel_driver(interface.bInterfaceNumber) which works, because "dmesg" logs it and the /dev/ttyUSB0 is released. but in the error stage it says exactly the same: Traceback (most recent call last): File "./pyusb.py", line 160, in <module> xdata_set_register(dev,UART1_MCR, MCR_DTR | MCR_RTS, 0xFF) File "./pyusb.py", line 136, in xdata_set_register print dev.ctrl_transfer(requesttype,command, value, moduleid, msg) File "/usr/local/lib/python2.6/site-packages/usb/core.py", line 668, in ctrl_transfer self.__get_timeout(timeout) File "/usr/local/lib/python2.6/site-packages/usb/_debug.py", line 53, in do_trace return f(*args, **named_args) File "/usr/local/lib/python2.6/site-packages/usb/backend/libusb10.py", line 541, in ctrl_transfer timeout)) File "/usr/local/lib/python2.6/site-packages/usb/backend/libusb10.py", line 356, in _check raise USBError(_str_error[retval.value]) usb.core.USBError: Input/output error In libusb10.py, this is the function raising the error: # check a libusb function call 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 raise USBError(_str_error[retval.value]) return retval That means, that the return value is less than cero, which means error in the lbusb call. Maybe because of my parameters. But the call is: dev.ctrl_transfer(requesttype,command, value, moduleid, msg) where all of them are integers excepting the msg parameter, which is an ordered list of integers between 0 and 255. Also the list of errors: # map return codes to strings _str_error = { _LIBUSB_SUCCESS:'Success (no error)', _LIBUSB_ERROR_IO:'Input/output error', _LIBUSB_ERROR_INVALID_PARAM:'Invalid parameter', _LIBUSB_ERROR_ACCESS:'Access denied (insufficient permissions)', _LIBUSB_ERROR_NO_DEVICE:'No such device (it may have been disconnected)', _LIBUSB_ERROR_NOT_FOUND:'Entity not found', _LIBUSB_ERROR_BUSY:'Resource busy', _LIBUSB_ERROR_TIMEOUT:'Operation timed out', _LIBUSB_ERROR_OVERFLOW:'Overflow', _LIBUSB_ERROR_PIPE:'Pipe error', _LIBUSB_ERROR_INTERRUPTED:'System call interrupted (perhaps due to signal)', _LIBUSB_ERROR_NO_MEM:'Insufficient memory', _LIBUSB_ERROR_NOT_SUPPORTED:'Operation not supported or unimplemented on this platform', _LIBUSB_ERROR_OTHER:'Unknown error' } discard other posibilities like timeout.. Can somebody give a better example on how to call ctrl_transfer with a data payload ? Thanks Diego NOTE: It is possible to call the detach function like this: dev.detach_kernel_driver(interface) if in the class definition of Interface we add self._as_parameter_ = self.bInterfaceNumber so ctypes automatically reads the interface number instead of giving a ctype error. ALSO the reattach doesnt work: /usr/lib/libusb-1.0.so.0: undefined symbol: libusb_attach_kernel_driver 2010/6/23 Xiaofan Chen <xiaof...@gmail.com>: > On Thu, Jun 24, 2010 at 9:08 AM, Diego Jacobi <jacobidi...@gmail.com> wrote: > >> There is a driver in the kernel for sure. >> Could you please expand your answer on this? >> How do i detach a driver from the kernel in user space? > > For libusb-0.1 > http://libusb.sourceforge.net/doc/function.usbdetachkerneldrivernp.html > For libusb-1.0 > http://libusb.sourceforge.net/api-1.0/group__dev.html#ga0bc7a17090debf6d2b2711c505ad9725 > > To run the above as a normal user, you have to have the proper > permission to do that (no need to being root), again the proper > way is to use udev rules. > >> Also the problem would be, that it is the driver the one that loads >> the firmware and initialices it. > > That is not a problem. After you attach the device, a driver > loads the firmware to the device. Then maybe the same driver > or a different driver is bound to the device with the firmware. > > To use libusb/pyusb, you detach the last driver bound to the > device. > >> I have had experiences where an HID device can receive usb >> transactions from a normal application. > > Even for HID device, you have to detach the kernel driver > if you want to use libusb/pyusb to communicate with the > device. > > > -- > 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