Christopher Moore wrote:
> I was wondering if there was a way to recover (aka regain communication 
> with the device) from a "Timer expired" message.  The only way I've 
> found so far is to physically re-plugin the device. 
I have a different approach to you, I have a class PlugUSBDevice which
initialises the device.  Here is a cut down version of how it is initalised:

class PlugUSBDevice(object) :

    PLUG_VENDOR_ID = 0x08D3
    PLUG_PRODUCT_ID = 0x0001
    PLUG_INTERFACE_ID = 0
    PLUG_BULK_IN_EP = 0x2
    PLUG_BULK_OUT_EP = 0x81
    MAX_PACKET_SIZE = 8

    def __init__(self) :
        self.device_descriptor = DeviceDescriptor(PlugUSBDevice.PLUG_VENDOR_ID,
                                                  PlugUSBDevice.PLUG_PRODUCT_ID,
                                                PlugUSBDevice.PLUG_INTERFACE_ID)
        self.handle = None
        self.devicestate = PlugUSBDevice.MIMIO_MODESTATE_INVALID
        self.greeted = 0
        self.currentMaxPacketSize = 8

    def open(self) :
        self.device = self.device_descriptor.getDevice()
        self.handle = self.device.open()
        self.handle.reset()
        if sys.platform == 'darwin' :
            # XXX : For some reason, Mac OS X doesn't set the
            # configuration automatically like Linux does.
            self.handle.setConfiguration(1)
        self.handle.claimInterface(self.device_descriptor.interface_id)
        #self.handle.setAltInterface(self.device_descriptor.interface_id)
        #print "handle", self.handle
        #print dir(self.handle)
        print "Claimed interface"

I then in my other routine call:

        self.plug = PlugUSBDevice()
        self.plug.open()

if something goes wrong I can just call open again and it resets the device.

Regards
Phil Hannent

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Pyusb-users mailing list
Pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to