X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=a31676ce0fed9976f94e930a6300fd5c2a39d51b;hp=43c0ca62a8117a57e807cf96a3bbe244c909e2a3;hb=fa5713a93ff59ebdd126f5b7914a96b5030b32fb;hpb=de633a9731ff7181ba4ef8afa288e57b5456598d diff --git a/client/GoodFET.py b/client/GoodFET.py index 43c0ca6..a31676c 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -48,7 +48,7 @@ class GoodFET: print "Verb %02x is wrong. Incorrect firmware?" % self.verb; #print "Connected." def getbuffer(self,size=0x1c00): - writecmd(0,0xC2,[size&0xFF,(size>>16)&&0xFF]); + writecmd(0,0xC2,[size&0xFF,(size>>16)&0xFF]); print "Got %02x%02x buffer size." % (self.data[1],self.data[0]); def writecmd(self, app, verb, count=0, data=[], blocks=1): """Write a command and some data to the GoodFET.""" @@ -60,11 +60,13 @@ class GoodFET: for d in data: self.serialport.write(chr(d)); + #self.serialport.flushOutput(); + #self.serialport.flushInput(); + + if not self.besilent: - #print "Reading reply to %02x/%02x." % (app,verb); self.readcmd(blocks); - #print "Read reply." - + besilent=0; app=0; verb=0; @@ -74,16 +76,21 @@ class GoodFET: def readcmd(self,blocks=1): """Read a reply from the GoodFET.""" while 1: + #print "Reading..."; self.app=ord(self.serialport.read(1)); + #print "APP=%2x" % self.app; self.verb=ord(self.serialport.read(1)); + #print "VERB=%02x" % self.verb; self.count=ord(self.serialport.read(1)); - self.data=self.serialport.read(self.count*blocks); + #print "Waiting for %i bytes." % self.count; + #print "READ %02x %02x %02x " % (self.app, self.verb, self.count); #Debugging string; print, but wait. if self.app==0xFF and self.verb==0xFF: - print "DEBUG %s" % self.data; + print "DEBUG %s" % self.serialport.read(self.count); else: + self.data=self.serialport.read(self.count*blocks); return self.data; #Monitor stuff