Flushing on DEBUG messages.
[goodfet] / client / GoodFET.py
index 5236b04..27ea0e5 100755 (executable)
@@ -109,20 +109,34 @@ class GoodFET:
             #Debugging string; print, but wait.
             if self.app==0xFF and self.verb==0xFF:
                 print "# DEBUG %s" % self.serialport.read(self.count);
+                sys.stdout.flush();
             else:
                 self.data=self.serialport.read(self.count);
                 return self.data;
     #Glitching stuff.
-    def glitchAPP(self,app):
+    def glitchApp(self,app):
         """Glitch into a device by its application."""
         self.data=[app&0xff];
         self.writecmd(self.GLITCHAPP,0x80,1,self.data);
         #return ord(self.data[0]);
-    def glitchVERB(self,app,verb, data):
-        """Glitch during a transaction.."""
+    def glitchVerb(self,app,verb,data):
+        """Glitch during a transaction."""
+        if data==None: data=[];
         self.data=[app&0xff, verb&0xFF]+data;
         self.writecmd(self.GLITCHAPP,0x81,len(self.data),self.data);
         #return ord(self.data[0]);
+    def glitchstart(self):
+        """Glitch into the AVR application."""
+        self.glitchVerb(self.APP,0x20,None);
+    def glitchstarttime(self):
+        """Measure the timer of the START verb."""
+        return self.glitchTime(self.APP,0x20,None);
+    def glitchTime(self,app,verb,data):
+        """Time the execution of a verb."""
+        if data==None: data=[];
+        self.data=[app&0xff, verb&0xFF]+data;
+        self.writecmd(self.GLITCHAPP,0x82,len(self.data),self.data);
+        return ord(self.data[0])+(ord(self.data[1])<<8);
     def glitchVoltages(self,low=0x0880, high=0x0fff):
         """Set glitching voltages. (0x0fff is max.)"""
         self.data=[low&0xff, (low>>8)&0xff,