X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETMCPCANCommunication.py;h=3350aa864f594d4d4e9967a370bcf2884265b85b;hp=9c9c48951075771851e97e06f941682f927dc415;hb=c6a361d308d1972ca9d371f515b0e7dd287627f5;hpb=fbd16932e0d96f1f9611d8a881b8eefe02f1f5cb diff --git a/client/GoodFETMCPCANCommunication.py b/client/GoodFETMCPCANCommunication.py index 9c9c489..3350aa8 100644 --- a/client/GoodFETMCPCANCommunication.py +++ b/client/GoodFETMCPCANCommunication.py @@ -20,6 +20,7 @@ import os from random import randrange from GoodFETMCPCAN import GoodFETMCPCAN; from intelhex import IntelHex; +import Queue class GoodFETMCPCANCommunication: @@ -72,7 +73,7 @@ class GoodFETMCPCANCommunication: # SNIFF ########################## - def sniff(self,freq,duration,description, verbose=True, comment=None, filename=None, standardid=None, debug=False, faster=False, parsed=True): + def sniff(self,freq,duration,description, verbose=True, comment=None, filename=None, standardid=None, debug=False, faster=False, parsed=True, data = None): #reset eveything on the chip self.client.serInit() @@ -152,7 +153,11 @@ class GoodFETMCPCANCommunication: packet=self.client.fastrxpacket(); else: packet=self.client.rxpacket(); - + + #add the data to list if the pointer was included + if(data != None): + #data.append(self.client.packet2parsedstr(packet)) + data.put(self.client.packet2parsed(packet)) if(debug == True): #check packet status MCPstatusReg = self.client.MCPrxstatus(); @@ -176,19 +181,19 @@ class GoodFETMCPCANCommunication: if( verbose==True): #if we want to print a parsed message if( parsed == True): -# packetParsed = self.client.packet2parsed(packet) -# sId = packetParsed.get('sID') -# msg = "sID: %04d" %sId -# if( packetParsed.get('eID')): -# msg += " eID: %d" %packetParsed.get('eID') -# msg += " rtr: %d"%packetParsed['rtr'] -# length = packetParsed['length'] -# msg += " length: %d"%length -# msg += " data:" -# for i in range(0,length): -# dbidx = 'db%d'%i -# msg +=" %03d"% ord(packetParsed[dbidx]) - msg = self.client.packet2parsedstr(packet) + packetParsed = self.client.packet2parsed(packet) + sId = packetParsed.get('sID') + msg = "sID: %04d" %sId + if( packetParsed.get('eID')): + msg += " eID: %d" %packetParsed.get('eID') + msg += " rtr: %d"%packetParsed['rtr'] + length = packetParsed['length'] + msg += " length: %d"%length + msg += " data:" + for i in range(0,length): + dbidx = 'db%d'%i + msg +=" %03d"% ord(packetParsed[dbidx]) + #msg = self.client.packet2parsedstr(packet) print msg # if we want to print just the message as it is read off the chip else: