X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=ef218333005c155af87cb76312e79ffba3475219;hp=0a3bf1ad633bf6087763acaafbfc56b8de5b14ed;hb=5ea4c9f824eed5226b9939b4f28fe1fda9c14dda;hpb=803a81c7aa96d7ca0333c7dfa5e662036758dfd1 diff --git a/client/GoodFET.py b/client/GoodFET.py index 0a3bf1a..ef21833 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -150,6 +150,7 @@ class GoodFET: break; if self.verbose: print "Connected after %02i attempts." % attempts; self.mon_connected(); + self.serialport.setTimeout(12); def telosSetSCL(self, level): self.serialport.setRTS(not level) def telosSetSDA(self, level): @@ -357,23 +358,32 @@ class GoodFET: """Execute supplied code.""" self.writecmd(0,0x31,2,#len(code), code); - def peekbyte(self,address): + def MONpeek8(self,address): """Read a byte of memory from the monitor.""" self.data=[address&0xff,address>>8]; self.writecmd(0,0x02,2,self.data); #self.readcmd(); return ord(self.data[0]); - def peekword(self,address): + def MONpeek16(self,address): """Read a word of memory from the monitor.""" - return self.peekbyte(address)+(self.peekbyte(address+1)<<8); + return self.MONpeek8(address)+(self.MONpeek8(address+1)<<8); def peek(self,address): """Read a word of memory from the monitor.""" - return self.peekbyte(address)+(self.peekbyte(address+1)<<8); + return self.MONpeek8(address)+(self.MONpeek8(address+1)<<8); def eeprompeek(self,address): """Read a word of memory from the monitor.""" - return self.peekbyte(address)+(self.peekbyte(address+1)<<8); - - def pokebyte(self,address,value): + return self.MONpeek8(address)+(self.MONpeek8(address+1)<<8); + def peekbysym(self,name): + """Read a value by its symbol name.""" + #TODO include memory in symbol. + reg=self.symbols.get(name); + return self.peek8(reg,"data"); + def pokebysym(self,name,val): + """Write a value by its symbol name.""" + #TODO include memory in symbol. + reg=self.symbols.get(name); + return self.pokebyte(reg,val); + def pokebyte(self,address,value,memory="vn"): """Set a byte of memory by the monitor.""" self.data=[address&0xff,address>>8,value]; self.writecmd(0,0x03,3,self.data); @@ -394,7 +404,7 @@ class GoodFET: def dumpmem(self,begin,end): i=begin; while i