update to threading of sniff on mainDisplay as well as added option to sniff in commu...
[goodfet] / client / GoodFETMCPCANCommunication.py
index b2d579f..107b6ea 100644 (file)
@@ -72,7 +72,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,6 +152,10 @@ 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(packet)
             
             if(debug == True):
                 #check packet status
@@ -442,7 +446,7 @@ class GoodFETMCPCANCommunication:
     # id for a given amount duration. This will be repeated the number of attempts time
     
     #at the moment this is set to switch to the next id once  a message is identified
-    def rtrSweep(self,freq,lowID,highID, attempts = 2,duration = 1, verbose = True):
+    def rtrSweep(self,freq,lowID,highID, attempts = 1,duration = 1, verbose = True):
         #set up file
         now = datetime.datetime.now()
         datestr = now.strftime("%Y%m%d")
@@ -451,11 +455,12 @@ 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)
+        #self.client.serInit()
+        #self.spitSetup(freq)
         for i in range(lowID,highID+1, 1):
+            self.client.serInit()
             self.spitSetup(freq)
             standardid = [i, i, i, i]
             #set filters
@@ -475,9 +480,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)
@@ -510,7 +517,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