diff usb488.py @ 11:f588f5bc834a

Add a method to determine if the device is still connected. This is really ham strung by libusb (or the FreeBSD implementation).
author Daniel O'Connor <darius@dons.net.au>
date Sat, 16 May 2009 23:33:52 +0930
parents 154dab1e474f
children 5ff9130cc953
line wrap: on
line diff
--- 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
+