changes to the GUI to allow for better loading and writing as well as tested our...
[goodfet] / client / GoodFETMCPCANCommunication.py
index 3350aa8..676d018 100644 (file)
@@ -155,9 +155,11 @@ class GoodFETMCPCANCommunication:
                 packet=self.client.rxpacket();
                 
             #add the data to list if the pointer was included
-            if(data != None):
+            if(data != None and packet != None):
                 #data.append(self.client.packet2parsedstr(packet))
-                data.put(self.client.packet2parsed(packet))
+                packetParsed = self.client.packet2parsed(packet)
+                packetParsed["time"] =time.time()
+                data.put(packetParsed)
             if(debug == True):
                 #check packet status
                 MCPstatusReg = self.client.MCPrxstatus();
@@ -554,7 +556,7 @@ class GoodFETMCPCANCommunication:
         self.spitSetup(freq);
         spit(self,freq, standardid, repeat, duration = None, debug = False, packet = None)
 
-    def spit(self,freq, standardid, repeat, duration = None, debug = False, packet = None):
+    def spit(self,freq, standardid, repeat,writes, period = None, debug = False, packet = None):
     
 
         #### split SID into different regs
@@ -597,19 +599,24 @@ class GoodFETMCPCANCommunication:
         
                 
         print "Transmitting packet: "
-        print self.client.packet2str(packet)
+        #print self.client.packet2str(packet)
                 
         self.client.txpacket(packet);
             
         if repeat:
             print "\nNow looping on transmit. "
-            if duration!= None:
-                starttime = time.time();
-                while((time.time()-starttime < duration)):
+            if period != None:
+                for i in range(0,writes):
                     self.client.MCPrts(TXB0=True);
-                    print "MSG printed"
+                    tic = time.time()
+                    time.sleep(period/1000) # pause for period ms before sending again
+                    print time.time()-tic
+                #starttime = time.time();
+                #while((time.time()-starttime < duration)):
+                #    self.client.MCPrts(TXB0=True);
+                #    print "MSG printed"
             else:
-                while(1): 
+                for i in range(0,writes): 
                     self.client.MCPrts(TXB0=True);
         print "messages injected"