From: Christopher M. <chr...@bn...> - 2008-12-15 14:05:45
|
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 |