r4663 - developers/werner/ahrt/host/tmc/lib

werner at docs.openmoko.org werner at docs.openmoko.org
Tue Sep 23 00:57:38 CEST 2008


Author: werner
Date: 2008-09-23 00:57:34 +0200 (Tue, 23 Sep 2008)
New Revision: 4663

Modified:
   developers/werner/ahrt/host/tmc/lib/decode.py
   developers/werner/ahrt/host/tmc/lib/dxplore.py
   developers/werner/ahrt/host/tmc/lib/instrument.py
Log:
Highlights:
- instrument debugging output is now configurable. Turn it all off with
  instrument.debug = False
- added x-axis ticks (quick and dirty - needs more work)
- CMD52 write decoding didn't print the value written (it showed up in the
  R5 response, though)

Details:
- lib/instrument.py: make debugging output configurable through
  instrument.debug_default and instrument().debug
- lib/dxplore.py (measurement.fn): changed order of measurements to make time
  the default
- lib/dxplore.py (main_window.update_zoom_area): renamed to update_zoom since
  it does a lot more now than just update the zoom area
- lib/dxplore.py (main_window): added a primitive form of ticks
- lib/decode.py (decode_arg): in CMD52, print the value written when writing,
  not when reading



Modified: developers/werner/ahrt/host/tmc/lib/decode.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/decode.py	2008-09-22 10:47:09 UTC (rev 4662)
+++ developers/werner/ahrt/host/tmc/lib/decode.py	2008-09-22 22:57:34 UTC (rev 4663)
@@ -118,7 +118,7 @@
     if cmd == 52:
 	s += (" ", "W")[(arg >> 27) & 1]
 	s += addr
-	if not write:
+	if write:
 	    s += ",0x%X" % (arg & 0xff)
 	return s
     if cmd == 53:

Modified: developers/werner/ahrt/host/tmc/lib/dxplore.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/dxplore.py	2008-09-22 10:47:09 UTC (rev 4662)
+++ developers/werner/ahrt/host/tmc/lib/dxplore.py	2008-09-22 22:57:34 UTC (rev 4663)
@@ -16,9 +16,10 @@
 #
 # TODO:
 # - clean up
-# - fix off-by-one error in selection
+# - fix occasional off-by-one error in left-hand side of selection
 # - add inversion
 # - add deglitching
+# - corner case: handle DC traces (sdio-121-A)
 #
 
 
@@ -220,8 +221,8 @@
 
     def __init__(self, master, t0, dt, prefix = ""):
         self.fn = (
+	  ( self.show_time, "s " ),
 	  ( self.show_samples, "Sa" ),
-	  ( self.show_time, "s " ),
 	  ( self.show_frequency, "Hz" ))
 
 	self.t0 = t0
@@ -325,9 +326,16 @@
     data_color = "white"
     zoom_color = "#808080"
 
+    tick_font = "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*",
+    tick_color = "#c0c0c0"
+    tick_mark_color = "#c07070"
+
+    si = ("p", "n", "u", "m", "", "k", "M", "G", "T")
+
     def __init__(self, master, d, t0, sample_step):
 	channels = len(d)
 	self.samples = len(d[0])
+	self.t0 = t0
 	self.sample_step = sample_step
 	self.xres = self.samples
 	self.yres = channels*50
@@ -337,7 +345,7 @@
 	self.wz = self.zoom_window(master)
 	self.w = self.main_window(master)
 	self.wt = self.tick_window(master)
-	self.wd = self.meas_window(master, t0)
+	self.wd = self.meas_window(master)
 	self.setup_events(master)
 	self.decode_from = None
 	self.user_pos = None
@@ -347,7 +355,7 @@
 	    self.ch.append(channel(self, ch, d[ch]))
 	    self.decoder_menu(self.w3, self.ch[-1], ch)
 	self.selected = None
-	self.update_zoom_area()
+	self.update_zoom()
 
     def geometry(self):
 	self.x0 = 0
@@ -370,13 +378,13 @@
 	  fill = self.background_color, width = 0)
 	return w
 
-    def meas_window(self, master, t0):
+    def meas_window(self, master):
 	w = Frame(master, width = self.xres, height = 20,
 	  bg = self.background_color)
 	w.pack(expand = 1, fill = "x")
 
 	self.meas_start = measurement(w, 0, self.sample_step, "SEL ")
-	self.meas_pos = measurement(w, t0, self.sample_step, "CUR ")
+	self.meas_pos = measurement(w, self.t0, self.sample_step, "CUR ")
 	self.meas_user = measurement(w, 0, self.sample_step, "USR ")
 	self.meas_width = measurement(w, 0, self.sample_step)
 
@@ -388,17 +396,20 @@
 	  activeforeground = measurement.color,
 	  activebackground = measurement.background_color)
 	self.status.pack(side = RIGHT, fill = "x")
+	return w
 
     def tick_window(self, master):
 	w = Canvas(master, width = self.xres, height = 20,
 	  bg = self.background_color)
 	w.pack(expand = 1, fill = "x")
+	return w
 
     def control_window(self, master):
 	w = Frame(master, width = 135, bg = self.background_color)
 	w.pack(side = LEFT, fill = BOTH, expand = 1)
 	b = Button(master, text = "Quit", relief = FLAT, command = master.quit)
 	b.place(x = 3, y = self.yres+16+self.zres+2)
+	return w
 
     def setup_events(self, master):
 	self.w.bind("<Motion>", self.move)
@@ -553,13 +564,14 @@
 	for ch in self.ch:
 	    ch.redraw()
 	self.cur.move(self.cur.x)
-	self.update_zoom_area()
+	self.update_zoom()
 
-    def update_zoom_area(self):
+    def update_zoom(self):
 	self.wz.coords(self.zoom_area,
 	  int(float(self.pos0)/self.samples*self.xres), 0,
 	  int(ceil((self.pos0+self.xres/self.mag)/self.samples*self.xres)),
 	  self.zres)
+
 	shown = min(self.samples, self.xres/self.mag)
 	if self.pos0 < 0:
 	    shown = min(shown, self.xres/self.mag+self.pos0)
@@ -576,6 +588,40 @@
 	  ("/", "x")[self.mag > 0.9],
 	  (1.0/self.mag, self.mag)[self.mag > 0.9]))
 
+	self.wt.delete("ticks")
+
+	tick_gap = 100
+	tick_inc, tick_exp, tick_unit = \
+	  self.tick_floor(self.sample_step*tick_gap/self.mag)
+	step = tick_inc*10**tick_exp
+	t0 = self.t0+self.sample_step*(self.pos0+self.x0/self.mag)
+	t1 = t0+self.sample_step*(self.xres-self.x0)/self.mag
+
+	for tick in range(int(t0*10/step+0.5), int(t1*10/step-0.5)+1):
+	    t = tick/10.0*step
+	    pos = (t-self.t0)/self.sample_step-self.pos0
+	    x = self.x0+pos*self.mag
+	    self.wt.create_line(x, 0, x, 5+4*((tick % 5) == 0),
+	      tags = "ticks", fill = self.tick_mark_color)
+	    if (tick % 10) == 0:
+		self.wt.create_text(x, 14,
+		  text = self.meas_status.pretty_float_trim(tick/10*step).
+		    translate(maketrans("", ""), " ")+"s",
+#		  text = str(tick/10*tick_inc)+tick_unit+"s",
+		  tags = "ticks",
+		  font = self.tick_font,
+		  fill = self.tick_color)
+
+    def tick_floor(self, step):
+	exp = -12
+	for unit in self.si:
+	    for dec in range(0, 3):
+		for i in range(0, 3):
+		    if step < (2, 5, 10)[i]*10**(exp+dec):
+			return int(round((1, 2, 5)[i]*10**dec)), exp, unit
+	    exp += 3
+	raise hell
+
     def button(self, event):
 	if self.decode_from is None:
 	    self.begin_decode()

Modified: developers/werner/ahrt/host/tmc/lib/instrument.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/instrument.py	2008-09-22 10:47:09 UTC (rev 4662)
+++ developers/werner/ahrt/host/tmc/lib/instrument.py	2008-09-22 22:57:34 UTC (rev 4663)
@@ -16,10 +16,6 @@
 # get/set functionality.
 #
 
-#
-# Known issue: settings can introduce new attributes. We should have a "lock"
-# method to prevent this. @@@@
-#
 
 import _tmc
 
@@ -136,17 +132,21 @@
 
 class instrument(settable):
 
+    debug_default = True
+
     def __init__(self, *args):
 	self.__tmc = _tmc.Instr(*args)
+	self.debug = self.debug_default
 	# Warning: "instrument" doesn't lock itself !
 
     def send(self, s):
-	print "SEND", s
+	if self.debug:
+	    print "SEND", s
 	self.__tmc.send(s)
 
     def read(self):
 	res = self.__tmc.read()
-	if len(res) < 100:
+	if self.debug and len(res) < 100:
 	    print "RECV", res
 	return res
 




More information about the commitlog mailing list