New graph, prohibitvely complex so disabled.
[goodfet] / client / GoodFETGlitch.py
index 96c8a19..056c50b 100644 (file)
@@ -22,6 +22,17 @@ with dots \
 title "Exploited"
 """;
 
+script_timevccrange="""
+plot "< sqlite3 glitch.db 'select time,vcc,glitchcount from glitches where count=0;'" \
+with dots \
+title "Scanned", \
+"< sqlite3 glitch.db 'select time,vcc,count from glitches where count>0;'" \
+with dots \
+title "Success", \
+"< sqlite3 glitch.db 'select time,max(vcc),count from glitches where count=0 group by time ;'" with lines title "Max", \
+"< sqlite3 glitch.db 'select time,min(vcc),count from glitches where count>0 group by time ;'" with lines title "Min"
+""";
+
 class GoodFETGlitch(GoodFET):
     
     def __init__(self, *args, **kargs):
@@ -29,6 +40,8 @@ class GoodFETGlitch(GoodFET):
         #Database connection w/ 30 second timeout.
         self.db=sqlite3.connect("glitch.db",30000);
         self.db.execute("create table if not exists glitches(time,vcc,gnd,trials,glitchcount,count,lock)");
+        self.db.execute("create index if not exists glitchvcc on glitches(vcc);");
+        self.db.execute("create index if not exists glitchtime on glitches(time);");
         self.client=0;
     def setup(self,arch="avr"):
         self.client=getClient(arch);
@@ -48,9 +61,10 @@ class GoodFETGlitch(GoodFET):
         g('set datafile separator "|"');
         
         g(script_timevcc);
+        print "^C to exit.";
         while 1==1:
             time.sleep(30);
-            g('replot');
+        #    g('replot');
 
         
     def graph(self):
@@ -76,7 +90,7 @@ class GoodFETGlitch(GoodFET):
         trials=1;
         lock=0;  #1 locks, 0 unlocked
         vstart=0;
-        vstop=1024;  #Could be as high as 0xFFF
+        vstop=0xfff;  #Could be as high as 0xFFF
         vstep=1;
         tstart=0;
         tstop=-1; #<0 defaults to full range
@@ -131,13 +145,9 @@ class GoodFETGlitch(GoodFET):
         c=self.db.cursor();
         c.execute("select vcc from glitches where vcc=? limit 1;",[vcc]);
         rows=c.fetchall();
-        try:
-            c.next(); 
-            #This voltage has been explored, because no complete exception has been thrown.
+        for a in rows:
             return True;
-        except: #Voltage hasn't been explored
-            return False;
-        
+        return False; 
     def scanat(self,trials,vcc,gnd,time):
         client=self.client;
         db=self.db;