Skip to content

Commit 37d7690

Browse files
committed
Minor improvements to RTT operation.
1 parent ac34970 commit 37d7690

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

rtt.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, cpu, adr):
4040
self.rd_ofs_adr = self.adr + 16
4141

4242
def get_name(self, adr):
43+
"""read and return the buffer name"""
4344
if adr == 0:
4445
return ''
4546
s = []
@@ -105,13 +106,15 @@ def text_dump(self, ui):
105106
if buf is None:
106107
return
107108
ui.put(buf.to_str())
109+
ui.flush()
108110

109111
def __str__(self):
110112
return '%s %d bytes @ 0x%08x' % (self.name, self.buf_size, self.buf_adr)
111113

112114
#-----------------------------------------------------------------------------
113115

114116
class rtt(object):
117+
"""rtt buffer operations"""
115118

116119
def __init__(self, cpu, mem):
117120
self.cpu = cpu
@@ -120,6 +123,7 @@ def __init__(self, cpu, mem):
120123
assert (mem.adr & 3 == 0) and (mem.size & 3 == 0), 'rtt ram must be 32 bit aligned'
121124
self.mem = mem
122125
self.adr = None
126+
self.t2h = self.h2t = None
123127
self.menu = (
124128
('init', self.cmd_init),
125129
('info', self.cmd_info),
@@ -166,10 +170,11 @@ def monitor(self, ui):
166170
def cmd_mon(self, ui, args):
167171
"""monitor and display the rtt buffers"""
168172
if self.adr is None:
169-
ui.put('%s\n' % _not_initialised)
170-
return
173+
self.cmd_init(ui, None)
174+
if self.adr is None:
175+
return
171176
ui.put('Monitoring target to host RTT buffers\nCtrl-D to exit\n')
172-
ui.cli.ln.loop(lambda : self.monitor(ui))
177+
ui.cli.ln.loop(lambda: self.monitor(ui))
173178

174179
def cmd_init(self, ui, args):
175180
"""initialise the rtt client"""
@@ -204,8 +209,9 @@ def cmd_init(self, ui, args):
204209
def cmd_info(self, ui, args):
205210
"""show rtt information"""
206211
if self.adr is None:
207-
ui.put('%s\n' % _not_initialised)
208-
return
212+
self.cmd_init(ui, None)
213+
if self.adr is None:
214+
return
209215
# print the rtt info
210216
cols = []
211217
cols.append(['rtt address', ': 0x%08x' % self.adr])

0 commit comments

Comments
 (0)