X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETMCPCAN.py;h=06047ff7ba3941c8e2a43906b6367d31afbcbf0b;hp=c740003b327cb7f39c6fe6ab2588256f75b4727b;hb=9e8ae94f53616cb9ef75279e21cda0bbcd9f232d;hpb=c731d103ee96698aa0a00198f0f6d6cc6381f0ab diff --git a/client/GoodFETMCPCAN.py b/client/GoodFETMCPCAN.py index c740003..06047ff 100644 --- a/client/GoodFETMCPCAN.py +++ b/client/GoodFETMCPCAN.py @@ -292,46 +292,41 @@ class GoodFETMCPCAN(GoodFETSPI): ## This code could be drastica - def packet2parsedstr(self,data): + def packet2parsed(self,data): dp1 = ord(data[0]) dp2 = ord(data[1]) dp5 = ord(data[4]) - #converts the CAN message to a string - msg=""; - - - + packet = {} #get the ide bit. allows us to check to see if we have an extended #frame - ide = (dp2 & 0x0f)>>3 + packet['ide'] = (dp2 & 0x0f)>>3 #we have an extended frame - if( ide != 0): + if( packet['ide'] != 0): #get lower nibble, last 2 bits eId = dp2 & 0x03 eId = eId<<8 | ord(data[2]) eId = eId<<8 | ord(data[3]) rtr = dp5>>6 & 0x01 - eIDmsg = " eID: %06d" %(eId) - rtrmsg = " rtr: %d" % (rtr) + packet['eID'] = " eID: %06d" %(eId) + packet['rtr'] = " rtr: %d" % (rtr) else: - rtr = dp2>>4 & 0x01 - eIDmsg = "" - rtrmsg = " rtr: %d"%(rtr) + packet['rtr'] = dp2>>4 & 0x01 + # Create the standard ID. from the message - sID = dp1<<3 | dp2>>5 - length = dp5 & 0x0f + packet['sID'] = dp1<<3 | dp2>>5 + packet['length'] = dp5 & 0x0f #generate the data section - dbmsg = "" for i in range(0,length): - dbmsg += data[idx] + idx = 5 + i + dbidx = 'db%d'%i + packet[dbidx] = data[idx] - msg = "sID: %04d" + eIDmsg + rtrmsg + ("length: %d"%(length)) + dbmsg - - return msg + + return packet def peek8(self,adr): @@ -376,4 +371,4 @@ class GoodFETMCPCAN(GoodFETSPI): # TXRTSCTRL = x0D - \ No newline at end of file +