X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=abfc16eae60632908b4f5341a2392f559517ea04;hp=5645f52b9174a96e5ed42130d2fa4aeaebdfbeb2;hb=ef8b3dcd43ed26a82df672e64396bf8c024bb09c;hpb=fbf1dcfd59f6213926c78178115c1b7110afdf8f diff --git a/client/GoodFET.py b/client/GoodFET.py index 5645f52..abfc16e 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -60,14 +60,26 @@ class GoodFET: self.readcmd(blocks); #Uncomment this later, to ensure a response. 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 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];