Interactive debugger, or parts of one.
[goodfet] / client / GoodFETConsole.py
1 #!/usr/bin/env python
2 # GoodFET Client Library
3
4 # (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
5 #
6 # This code is being rewritten and refactored.  You've been warned!
7
8 import sys;
9 import binascii;
10
11 from GoodFET import GoodFET;
12 from intelhex import IntelHex;
13
14 class GoodFETConsole():
15     """An interactive goodfet driver."""
16     
17     def __init__(self, client):
18         self.client=client;
19         client.serInit();
20         client.setup();
21         client.start();
22     def handle(self, str):
23         """Handle a command string.  First word is command."""
24         args=str.split();
25         if len(args)==0:
26             return;
27         try:
28             eval("self.CMD%s(args)" % args[0])
29         except AttributeError:
30             print "Unknown command '%s'." % args[0];
31     def CMDinfo(self,args):
32         print self.client.infostring()
33     def CMDlock(self,args):
34         print "Locking.";
35         self.client.lock();
36     def CMDerase(self,args):
37         print "Erasing.";
38         self.client.erase();
39     def CMDtest(self,args):
40         self.client.test();
41         return;
42     def CMDstatus(self,args):
43         print self.client.status();
44         return;
45     def CMDpeek(self,args):
46         adr=eval(args[1]);
47         print "0x%08x:= 0x%04x" % (adr, self.client.peek16(adr));
48         return;
49