changes to mainDisplay.py
authorchrishoder <chrishoder@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 30 Jan 2013 02:38:17 +0000 (02:38 +0000)
committerchrishoder <chrishoder@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 30 Jan 2013 02:38:17 +0000 (02:38 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1431 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETMCPCAN.py
client/GoodFETMCPCANCommunication.py

index 8785fed..d99e07c 100644 (file)
@@ -245,6 +245,45 @@ class GoodFETMCPCAN(GoodFETSPI):
                             ]);
         print "about to transmit:" + self.packet2str(data[2:len(data)]);
         
+
+    def simpleParse(self,packet):
+        dataPt = ord(packet[0]);
+        dataPt2 = ord(packet[1]);
+        # check if we have a standard frame, the msb of the second
+        # nibble will be 1. otherwise it is an extended rame
+        stdCheck = dataPt2 & 0x0f
+        if( stdCheck == 16 ):
+            #arb id is first byte + 3 msb of the 2nd byte
+            dataPt = dataPt<<3 | dataPt2>>5
+            print "Standard Packet \n Arb ID: "+("%d"%dataPt)
+        else:
+            #arb id is first byte + 3 msb + 2 lsb of 2nd byte +
+            # 3rd byte + 4th byte
+            dataPt = dataPt<<3 | dataPt2>>5
+            dataPt = dataPt<<2 | (dataPt2 & 0x03)
+            dataPt = dataPt<<8 | ord(packet[2])
+            dataPt = dataPt<<8 | ord(packet[3])
+            print "Extended Data Frame \n Arb ID: "+("%d"%dataPt)
+        
+        #find the dataLength
+        dataPt5 = packet[4]
+        dataLength = dataPt5 & 0x0e
+        print "Data Length: "+("%d"%dataLength)
+        # Print the data packet
+        print "Data:"
+        # Temporary, until correct packets are read
+        if( dataLength > 8 ):
+            dataLength = 8
+        toprint = self.pcket2str(packet[5:12])
+        print toprint
+        # For reading correct packets
+       # if (dataLength > 8 ):
+        #    print "Acceptable Length Exceeded"
+            # Data length value should never exceed 8
+       # else:
+       # toprint =  self.pcket2str(packet[5:(5+dataLength)])
+       # print toprint
+
     def txpacket(self,packet):
         """Transmits a packet through one of the outbound buffers.
         As usual, the packet should begin with SIDH.
index 3daa571..41a8cce 100644 (file)
@@ -438,15 +438,15 @@ class GoodFETMCPCANCommunication:
         checkcount = 0;
         TXB0CTRL = self.client.peek8(0x30);
         
-      #  while(TXB0CTRL | 0x00 != 0x00):
-      #      checkcount+=1;
-      #      TXB0CTRL = self.client.peek8(0x30);
-      #      if (checkcount %30 ==0):
-      #          print "Tx Errors:  %3d" % self.client.peek8(0x1c);
-      #          print "Rx Errors:  %3d" % self.client.peek8(0x1d);
-      #          print "EFLG register:  %02x" % self.client.peek8(0x2d);
-      #          print "TXB0CTRL: %02x" %TXB0CTRL;
-      #          print "CANINTF: %02x\n"  %self.client.peek8(0x2C);
+        while(TXB0CTRL | 0x00 != 0x00):
+            checkcount+=1;
+            TXB0CTRL = self.client.peek8(0x30);
+            if (checkcount %30 ==0):
+                print "Tx Errors:  %3d" % self.client.peek8(0x1c);
+                print "Rx Errors:  %3d" % self.client.peek8(0x1d);
+                print "EFLG register:  %02x" % self.client.peek8(0x2d);
+                print "TXB0CTRL: %02x" %TXB0CTRL;
+                print "CANINTF: %02x\n"  %self.client.peek8(0x2C);
 
 
     def setRate(self,freq):