From: Santiago P. Sanchez-M. <sp...@gm...> - 2008-12-15 15:19:10
|
I think you need to release (de-claim) the device before closing your app. handle.close() maybe ... long time since I programmed with the lib On Mon, Dec 15, 2008 at 2:24 PM, Christopher Moore <chr...@bn...>wrote: > Please forgive the cross-post with libusb, but I was wondering if there > was a specific pyUSB solution to my problem. > > Hey everyone, > > I'm encountering a problem with my script (it's Python) that causes my > program to crash, probably mid-transfer between the program and the usb > device (in my case this is a usb phone). > > When I try to re-launch my program, it gives me the following error: > > handle.getDescriptor(usb.DT_REPORT,0,0x9c,usb.ENDPOINT_OUT) > usb.USBError: error sending control message: Timer expired > > Basically, when my program starts, it tries to find the device, via a for > loop through the usb busses. It verifies what it finds against a > vendor/product ID and then tries to get a report descriptor from the > device (as seen above). > > If I try to re-launch my program, I always get this error and the only way > around this is to physically re-plug my device. > > I've tried to "re-claim" the interface and also do a "reset" on the > device, but neither work. > > below is a snippet of the relevant code: > > -------------------- > > def phone_INITIALIZE(): > """this function initializes and takes control of the phone so we > can > communicate with it""" > > global handle > global endpoint > > # linksys CIT200 Device Info > vendor_id = 5041 > product_id = 29 > > buses = usb.busses() > > for bus in buses : > for device in bus.devices : > if device.idVendor == vendor_id : > if device.idProduct == product_id : > # found the CIT200 > print "Found Linksys Device ..." > linksys = device > > # open device > handle = linksys.open() > > # setup interface and configs ... there are 4 interfaces for this > device... > config = linksys.configurations[0] > interface = config.interfaces[3][0] > endpoint = interface.endpoints[0] > > try: > # claim and set the interface > handle.claimInterface(interface) > handle.setAltInterface(interface) > except usb.USBError: > # detach the hid interface > handle.detachKernelDriver(3) > > # get device descriptor > handle.getDescriptor(usb.DT_REPORT,0,0x9c,usb.ENDPOINT_OUT) > > # send idle message > handle.controlMsg(0x21,0x0a,0,0,0x03) > > -------------------- > > Any help would be appreciated. > > Thanks > > Christopher > > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Pyusb-users mailing list > Pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > |