minor bug fix on parsing experiments data
authorchrishoder <chrishoder@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 13 Feb 2013 03:27:42 +0000 (03:27 +0000)
committerchrishoder <chrishoder@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 13 Feb 2013 03:27:42 +0000 (03:27 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1483 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/FordExperiments.py
client/GoodFETMCPCAN.py
client/GoodFETMCPCANCommunication.py

index 5853645..326cf2e 100644 (file)
@@ -142,6 +142,25 @@ class FordExperiments(GoodFETMCPCANCommunication):
             
         #recieveTime = time.time()
         return packetParsed
+
+    def cycle4packets1279(self):
+        self.client.serInit()
+        self.spitSetup(500)
+        # filter on 1279
+        self.addFilter([1279, 1279, 1279, 1279, 1279, 1279], verbose = False)
+        packetParsed = self.getBackground(1279)
+        packet = []
+        if (packetParsed[db0] == 16):
+            # if it's the first of the four packets, replace the value in db7  with 83
+            packetParsed[db7] = 83
+            # transmit new packet
+            self.client.txpacket(packetParsed)
+        else:
+        # otherwise, leave it alone
+            # transmit same pakcet we read in
+            self.client.txpacket(packetParsed)
+        # print the packet we are transmitting
+        print packetParsed
         
         
     def oscillateTemperature(self,time):
index 0232b28..46c8ec4 100644 (file)
@@ -329,7 +329,7 @@ class GoodFETMCPCAN(GoodFETSPI):
     
     def packet2parsedstr(self,data):
         packet = self.packet2parsed(data)
-        msg = "sID: %04d" %sId
+        msg = "sID: %04d" %packet['sId']
         if( packetParsed.get('eID')):
             msg += " eID: %d" %packetParsed.get('eID')
         msg += " rtr: %d"%packetParsed['rtr']
index 6aee2ef..6af64ff 100644 (file)
@@ -237,8 +237,8 @@ class GoodFETMCPCANCommunication:
                 for byte in packet:
                     row.append("%02x"%ord(byte));
                 dataWriter.writerow(row);
-        
-        outfile.close()
+        if(writeToFile == True):
+            outfile.close()
         print "Listened for %d seconds, captured %d packets." %(duration,packetcount);
         return packetcount