# HG changeset patch # User Daniel O'Connor # Date 1242482632 -34200 # Node ID f588f5bc834acc0bf1dad9d361a2d676a4c47bdf # Parent 154dab1e474f2173e6121ad7bf9bf109d40d7e46 Add a method to determine if the device is still connected. This is really ham strung by libusb (or the FreeBSD implementation). diff -r 154dab1e474f -r f588f5bc834a usb488.py --- a/usb488.py Sat May 16 23:33:20 2009 +0930 +++ b/usb488.py Sat May 16 23:33:52 2009 +0930 @@ -278,3 +278,15 @@ return result + def isConnected(self): + """Check if the device is present""" + + # libusb makes it very hard (at least on FreeBSD) to determine if we're still connected. + # This is a reasonable proxy.. + try: + self.handle.getString(self.dev.iManufacturer, 100) + except USBError, e: + return False + + return True +