X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=af24201cbcd74b8db97c041bdc157678e7487484;hp=5645f52b9174a96e5ed42130d2fa4aeaebdfbeb2;hb=1706a7f4cfa73ed716b56f5b0322bfb67b560ade;hpb=fbf1dcfd59f6213926c78178115c1b7110afdf8f diff --git a/client/GoodFET.py b/client/GoodFET.py index 5645f52..af24201 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -47,6 +47,9 @@ class GoodFET: if(self.verb!=0x7F): print "Verb %02x is wrong. Incorrect firmware?" % self.verb; #print "Connected." + def getbuffer(self,size=0x1c00): + 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.""" self.serialport.write(chr(app)); @@ -57,17 +60,45 @@ class GoodFET: for d in data: self.serialport.write(chr(d)); - self.readcmd(blocks); #Uncomment this later, to ensure a response. + if not self.besilent: + #print "Reading reply to %02x/%02x." % (app,verb); + self.readcmd(blocks); + #print "Read reply." + + besilent=0; + app=0; + verb=0; + count=0; + data=""; + def readcmd(self,blocks=1): """Read a reply from the GoodFET.""" - self.app=ord(self.serialport.read(1)); - self.verb=ord(self.serialport.read(1)); - self.count=ord(self.serialport.read(1)); - self.data=self.serialport.read(self.count*blocks); - #print "READ %02x %02x %02x " % (self.app, self.verb, self.count); - return self.data; - + while 1: + self.app=ord(self.serialport.read(1)); + self.verb=ord(self.serialport.read(1)); + self.count=ord(self.serialport.read(1)); + self.data=self.serialport.read(self.count*blocks); + #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; + else: + return self.data; + #Monitor stuff + def silent(self,s=0): + """Transmissions halted when 1.""" + self.besilent=s; + print "besilent is %i" % self.besilent; + self.writecmd(0,0xB0,1,[s]); + + def out(self,byte): + """Write a byte to P5OUT.""" + self.writecmd(0,0xA1,1,[byte]); + def dir(self,byte): + """Write a byte to P5DIR.""" + self.writecmd(0,0xA0,1,[byte]); def peekbyte(self,address): """Read a byte of memory from the monitor.""" self.data=[address&0xff,address>>8];