Automatic port scanning for Windows.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 24 May 2010 05:21:19 +0000 (05:21 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 24 May 2010 05:21:19 +0000 (05:21 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@565 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFET.py
client/goodfet

index e0f6431..8244aaa 100755 (executable)
@@ -89,7 +89,14 @@ class GoodFET:
             glob_list = glob.glob("/dev/ttyUSB*");
             if len(glob_list) > 0:
                 port = glob_list[0];
             glob_list = glob.glob("/dev/ttyUSB*");
             if len(glob_list) > 0:
                 port = glob_list[0];
-        
+        if os.name=='nt':
+            from scanwin32 import winScan;
+            scan=winScan();
+            for order,comport,desc,hwid in sorted(scan.comports()):
+                if hwid.index('FTDI')==0:
+                    port=comport;
+                    #print "Using FTDI port %s" % port
+                    
         
         self.serialport = serial.Serial(
             port,
         
         self.serialport = serial.Serial(
             port,
index 070f810..c8e2187 100755 (executable)
@@ -26,25 +26,26 @@ if verb=="scan":
     from scanwin32 import *;
     # INIT COMPORT SCAN
     scan=winScan();
     from scanwin32 import *;
     # INIT COMPORT SCAN
     scan=winScan();
-    scan.comports();
-
+    #scan.comports();
+    
     for order, port, desc, hwid in sorted(scan.comports()):
         # Look for FTDIBUS
         try:
     for order, port, desc, hwid in sorted(scan.comports()):
         # Look for FTDIBUS
         try:
-            hwid.index('FTDI')
-            print "*************"
-            print "GOODFET FOUND"
-            print "*************"
-            print "%s: (%s) ->" % (port, hwid),
+            #hwid.index('FTDI')
+            #print "*************"
+            #print "GOODFET FOUND"
+            #print "*************"
+            if hwid.index('FTDI')!=0: continue;
+            print "%s: (%s)" % (port, hwid),
             try:
                 serial.Serial(port)
             except serial.serialutil.SerialException:
             try:
                 serial.Serial(port)
             except serial.serialutil.SerialException:
-                print "Not Ready - Is the process in use?"
+                print "Busy"
             else:
                 print "Ready"
         except:
             pass
             else:
                 print "Ready"
         except:
             pass
-
+    sys.exit(0);
 
 driver=sys.argv[1];
 print "Using driver %s" % driver;
 
 driver=sys.argv[1];
 print "Using driver %s" % driver;