added display to the mainDisplay that shows packets streaming
[goodfet] / client / GoodFETMCPCANCommunication.py
index 3ab84b2..a907372 100644 (file)
@@ -20,6 +20,7 @@ import os
 from random import randrange
 from GoodFETMCPCAN import GoodFETMCPCAN;
 from intelhex import IntelHex;
+import Queue
 
 class GoodFETMCPCANCommunication:
     
@@ -72,7 +73,7 @@ class GoodFETMCPCANCommunication:
     #   SNIFF
     ##########################
          
-    def sniff(self,freq,duration,description, verbose=True, comment=None, filename=None, standardid=None, debug=False, faster=False, parsed=True):
+    def sniff(self,freq,duration,description, verbose=True, comment=None, filename=None, standardid=None, debug=False, faster=False, parsed=True, data = None):
         
         #reset eveything on the chip
         self.client.serInit() 
@@ -152,7 +153,11 @@ class GoodFETMCPCANCommunication:
                 packet=self.client.fastrxpacket();
             else:
                 packet=self.client.rxpacket();
-            
+                
+            #add the data to list if the pointer was included
+            if(data != None):
+                #data.append(self.client.packet2parsedstr(packet))
+                data.put(self.client.packet2parsedstr(packet))
             if(debug == True):
                 #check packet status
                 MCPstatusReg = self.client.MCPrxstatus();
@@ -451,7 +456,7 @@ class GoodFETMCPCANCommunication:
         outfile = open(filename,'a');
         dataWriter = csv.writer(outfile,delimiter=',');
         dataWriter.writerow(['# Time     Error        Bytes 1-13']);
-        dataWriter.writerow(['#' + "rtr sweep from " + lowID + " to" + highID])
+        dataWriter.writerow(['#' + "rtr sweep from %d to %d"%(lowID,highID)])
         print "started"
         #self.client.serInit()
         #self.spitSetup(freq)
@@ -476,9 +481,11 @@ class GoodFETMCPCANCommunication:
             self.client.txpacket(packet)
             ## listen for 2 packets. one should be the rtr we requested the other should be
             ## a new packet response
-            starttime = time.tim()
+            starttime = time.time()
             while ((time.time() - starttime) < duration):
                 packet = self.client.rxpacket()
+                if( packet == None):
+                    continue
                 row = []
                 row.append("%f"%time.time()) #timestamp
                 row.append(0) #error flag (not checkign)
@@ -511,7 +518,6 @@ class GoodFETMCPCANCommunication:
                 while( (time.time()-starttime) < duration):
                     packet=self.client.rxpacket();
                     row = []
-                    row = []
                     row.append("%f"%time.time()) #timestamp
                     row.append(0) #error flag (not checking)
                     row.append("rtrRequest_%d"%i) #comment