updated some new experiment methods. you can now fuzz on all ids randomly as well...
[goodfet] / client / FordExperiments.py
index 357ba6c..e826bca 100644 (file)
@@ -11,16 +11,21 @@ from intelhex import IntelHex;
 import Queue
 import math
 
-class FordExperiments(GoodFETMCPCANCommunication):
+tT = time
+class FordExperiments(GoodFETMCPCANCommunication, dataLocation):
     
-    def init(self):
-        super(FordExperimetns,self).__init__(self) #initialize chip
+    def __init__(self):
+        GoodFETMCPCANCommunication.__init__(self, dataLocation)
+        #super(FordExperiments,self).__init__(self) #initialize chip
         self.freq = 500;
 
+    
+
+
     def mimic1056(self,packetData,runTime):
         #setup chip
         self.client.serInit()
-        self.spitSetup(500)
+        self.spitSetup(self.freq)
         #FIGURE out how to clear buffers
         self.addFilter([1056, 1056, 1056, 1056,1056, 1056], verbose=False)
         packet1 = self.client.rxpacket();
@@ -138,8 +143,27 @@ class FordExperiments(GoodFETMCPCANCommunication):
             if(packet1 != None):
                 packetParsed = self.client.packet2parsed(packet1)
             
-        recieveTime = time.time()
+        #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):
@@ -167,11 +191,17 @@ class FordExperiments(GoodFETMCPCANCommunication):
                  packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7]]
         packetCount = 1;
         self.client.txpacket(packet);
-        tpast = time.time()
-        while( (time.time()-recieveTime) < runTime):
-            dt = tpast - time.time()
-            value = 30*math.sin(((2.0*math.pi)/5.0)*dt)+130
-            packet[5] = int(value)
+        startTime = tT.time()
+        while( (tT.time()-startTime) < runTime):
+            dt = tT.time()-startTime
+            inputValue = ((2.0*math.pi)/20.0)*dt
+            value = 30*math.sin(inputValue)+130
+            print value
+            #packet[5] = int(value)
+            if( value > 130 ):
+                packet[5] = 160
+            else:
+                packet[5] = 100
             #packet[6] = 1
             print packet
             self.client.txpacket(packet)
@@ -187,4 +217,4 @@ if __name__ == "__main__":
     runTime = 100;
     #fe.mimic1056(packetData, runTime)
     #fe.cycledb1_1056(runTime)
-    fe.oscillateTemperature(runTime)
\ No newline at end of file
+    fe.oscillateTemperature(runTime)