X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETConsole.py;h=a7eccd32f6b7bf43667be5206b0c07dbf9cfa795;hp=cd0045f01cc59aa67386a58a752e28b06671d4ac;hb=f7fdc48f01ada713d5034763a2f3395fe2a7c51b;hpb=d941137f767ad40f7bf253f6828735b641b52dca diff --git a/client/GoodFETConsole.py b/client/GoodFETConsole.py index cd0045f..a7eccd3 100644 --- a/client/GoodFETConsole.py +++ b/client/GoodFETConsole.py @@ -11,6 +11,23 @@ import binascii; from GoodFET import GoodFET; from intelhex import IntelHex; + +#grep CMD GoodFETConsole.py | grep def | sed s/\(sel.\*// | sed 's/def CMD//' +commands=""" + info + lock + erase + test + status + halt + resume + peek + flash + dump + where + chip +""" + class GoodFETConsole(): """An interactive goodfet driver.""" @@ -19,15 +36,26 @@ class GoodFETConsole(): client.serInit(); client.setup(); client.start(); + client.loadsymbols(); + def prompt(self): + sys.stdout.write("gf% "); + sys.stdout.flush(); def run(self): + self.prompt(); + #for cmd in sys.stdin: while 1: - sys.stdout.write("gf% "); - sys.stdout.flush(); cmd=sys.stdin.readline(); - self.handle(cmd); - + if not cmd: break; + if(cmd.strip()!=""): + self.handle(cmd); + self.prompt(); def handle(self, str): """Handle a command string. First word is command.""" + #Lines beginning with ? are cries for help. + if(str[0]=="?"): + print "Term Commands:" + print commands + return; #Lines beginning with # are comments. if(str[0]=="#"): return; #Lines beginning with ! are Python. @@ -64,15 +92,37 @@ class GoodFETConsole(): def CMDstatus(self,args): print self.client.status(); return; + def CMDhalt(self,args): + print self.client.halt(); + def CMDresume(self,args): + print self.client.resume(); def CMDpeek(self,args): - adr=eval(args[1]); + adr=args[1]; memory="vn"; if(len(args)>2): memory=args[2]; - print "0x%08x:= 0x%04x" % (adr, self.client.peek16(adr,memory)); + adr= self.client.name2adr(adr); + #print "%i" % adr; + print "0x%08x:= 0x%04x" % ( + adr, self.client.peek16(adr, + memory)); def CMDflash(self,args): file=args[1]; self.client.flash(self.expandfilename(file)); + def CMDdump(self,args): + file=args[1]; + self.client.dump(self.expandfilename(file)); + def CMDwhere(self,args): + pc=self.client.getpc(); + print "PC=0x%04X" % pc; + def CMDchip(self,args): + cmd="self.client.CMD%s()" % args[1]; + print cmd; + try: + eval(cmd); + except: + print sys.exc_info()[0]; + print "Chip-specific command failed."; def expandfilename(self,filename): if(filename[0]=='~'): return "%s%s" % (os.environ.get("HOME"),filename.lstrip('~'));