changes to run client on windows platform too via libusb dev

Fri, 17 Feb 2017 13:26:39 +0100

author
mbayer
date
Fri, 17 Feb 2017 13:26:39 +0100
changeset 6
b84252fe69c6
parent 5
06ccfef112fc
child 7
16e4becf8b1b

changes to run client on windows platform too via libusb dev

analgauge.py file | annotate | diff | comparison | revisions
--- a/analgauge.py	Thu Feb 16 16:24:52 2017 +0100
+++ b/analgauge.py	Fri Feb 17 13:26:39 2017 +0100
@@ -1,11 +1,24 @@
+"""
+Simple CPU load Display
+
+On Linux simply run with
+    python analgauge.py &
+
+On Windows:
+    Make sure to install libusb-win32-devel-filter-1.2.6.0.exe
+    from here: https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/
+    Then assign a filter to the connected device matching VENDOR_ID and PRODUCT_ID
+
+    pythonw.exe analgauge.py
+"""
 import usb.core
 from psutil import cpu_percent
 from time import sleep
 from random import random
-from sys import exit
+from sys import exit, platform
 
 #VALUE_MIN = 0x00 # TODO
-VALUE_MAX = 0x7B
+VALUE_MAX = 0x78
 
 VENDOR_ID = 0x16c0
 PRODUCT_ID = 0x05df
@@ -19,6 +32,7 @@
         if not self.dev:
             print "AnalGauge Device not found!"
             exit(1)
+        self.dev.set_configuration()
 
     def update(self, d):
         try:
@@ -29,7 +43,10 @@
                 data_or_wLength = data
                 )
         except usb.core.USBError, e:
-            self.dev.detach_kernel_driver(0)
+            if platform == "linux":
+                self.dev.detach_kernel_driver(0)
+            else:
+                exit(1)
             print(e)
 
 if __name__ == "__main__":

mercurial