Bluetooth reliability fix, for packets that weren't quite received or transmitted.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 29 Aug 2011 12:17:42 +0000 (12:17 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 29 Aug 2011 12:17:42 +0000 (12:17 +0000)
Might be necessary for some usb/serial adapters other than the FTDI.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1041 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFET.py
client/goodfet.monitor

index 4e42bc5..395383b 100755 (executable)
@@ -83,10 +83,15 @@ class GoodFETbtser:
         
     def write(self,msg):
         """Send traffic."""
         
     def write(self,msg):
         """Send traffic."""
+        import time;
+        time.sleep(0.1);
         return self.sock.send(msg);
         return self.sock.send(msg);
-    def read(self,len):
+    def read(self,length):
         """Read traffic."""
         """Read traffic."""
-        return self.sock.recv(len);
+        data="";
+        while len(data)<length:
+            data=data+self.sock.recv(length-len(data));
+        return data;
 class GoodFET:
     """GoodFET Client Library"""
 
 class GoodFET:
     """GoodFET Client Library"""
 
@@ -122,7 +127,7 @@ class GoodFET:
             self.pyserInit(port,timeout,attemptlimit);
     def btInit(self, port, timeout, attemptlimit):
         """Open a bluetooth port.""";
             self.pyserInit(port,timeout,attemptlimit);
     def btInit(self, port, timeout, attemptlimit):
         """Open a bluetooth port.""";
-        #self.verbose=True;  #For debugging BT.
+        self.verbose=True;  #For debugging BT.
         self.serialport=GoodFETbtser(port);
         
     def pyserInit(self, port, timeout, attemptlimit):
         self.serialport=GoodFETbtser(port);
         
     def pyserInit(self, port, timeout, attemptlimit):
@@ -353,8 +358,8 @@ class GoodFET:
                     +(ord(self.serialport.read(1))<<8)
                     );
 
                     +(ord(self.serialport.read(1))<<8)
                     );
 
-                #if self.verbose:
-                #print "Rx: ( 0x%02x, 0x%02x, 0x%04x )" % ( self.app, self.verb, self.count )
+                if self.verbose:
+                    print "Rx: ( 0x%02x, 0x%02x, 0x%04x )" % ( self.app, self.verb, self.count )
             
                 #Debugging string; print, but wait.
                 if self.app==0xFF:
             
                 #Debugging string; print, but wait.
                 if self.app==0xFF:
index d11b422..67ec3fb 100755 (executable)
@@ -62,7 +62,7 @@ if(sys.argv[1]=="clocktest"):
         client.monitorsetclock(clocking-foo);
         print "-0x%04x: %s" % (foo,client.infostring());
         
         client.monitorsetclock(clocking-foo);
         print "-0x%04x: %s" % (foo,client.infostring());
         
-if(sys.argv[1]=="listapps"):
+if(sys.argv[1]=="listapps" or sys.argv[1]=="apps"):
     full = (len(sys.argv) > 2) and (sys.argv[2]=="full")
     client.monitor_list_apps(full);
     
     full = (len(sys.argv) > 2) and (sys.argv[2]=="full")
     client.monitor_list_apps(full);