summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNélio Laranjeiro2009-07-13 15:54:03 +0200
committerNélio Laranjeiro2009-07-13 15:54:03 +0200
commit41813460998b22f7ea3ac35ae6f8f9cda3886ac9 (patch)
treea8f4ace3b99cad1cab1f8ba121515c9a6327f431 /tools
parentccbfefb674166ac5cd95d737a019c88d5a20d3a8 (diff)
*tools/trace, digital/avr/modules/flash, digital/avr/modules/trace:
* Added the flash host file support for simulator tests. * Removed in the python tool the memory space in double when receiving from the proto object.
Diffstat (limited to 'tools')
-rw-r--r--tools/trace/tinter/thost.py39
-rw-r--r--tools/trace/tinter/tinter.py21
-rw-r--r--tools/trace/trace.py2
3 files changed, 41 insertions, 21 deletions
diff --git a/tools/trace/tinter/thost.py b/tools/trace/tinter/thost.py
index f888a242..df614565 100644
--- a/tools/trace/tinter/thost.py
+++ b/tools/trace/tinter/thost.py
@@ -27,19 +27,30 @@ class THost:
else:
self.__proto = Proto (serial.Serial (prgm), time.time, 0.1)
self.__memory = list()
+ self.__memory_addr = list()
self.__traces = []
+ def __dump_callback_addr (self, addr):
+ """Callback providing the address of the data which will be
+ returned."""
+ self.__memory_addr.append (addr)
+
def __dump_callback (self, *memory):
"""Callback call on each data reception"""
- not_ff = False
+ not_ffff = False
+ data = []
for i in range(len (memory)):
- if memory[i] != 0xff:
- not_ff = True
- self.__memory.append (memory[i])
- if not not_ff:
+ if (i < len(memory) -1) and ((memory[i] << 8)
+ | (memory[i+1])) != 0xffff:
+ not_ffff = True
+ data.append (memory[i])
+
+ if not not_ffff:
self.__proto.flush ()
sys.stderr.write (".")
+ self.__memory.append (data)
+
def __trace_present (self, val):
"""Get the trace value and the first byte following."""
self.__traces.append (val)
@@ -62,7 +73,7 @@ class THost:
# Initialise the flash access.
self.__proto.register ('r', FLASH_BUFFER_SIZE * 'B',
self.__dump_callback)
- self.__proto.register ('r', 'B', self.__trace_present)
+ self.__proto.register ('a', 'I', self.__dump_callback_addr)
i = 0
self.__traces.append (0x100)
@@ -72,7 +83,6 @@ class THost:
self.__proto.send ('l', 4*'b', FLASH_CMD_READ, addr, 0, 0)
self.__proto.wait (lambda: True)
i += FLASH_PAGE
- i -= FLASH_PAGE
start_addr = i
end_addr = start_addr + FLASH_PAGE
@@ -87,4 +97,17 @@ class THost:
def get_trace (self):
"""Return the traces dumped from the flash memory."""
- return self.__memory[1:]
+ mem = []
+ i = 0
+ while i < len (self.__memory_addr):
+ if self.__memory_addr[i] == self.__memory_addr[i-1]:
+ self.__memory_addr.remove(self.__memory_addr[i])
+ self.__memory.remove(self.__memory[i])
+ else:
+ i += 1
+
+ for i in self.__memory:
+ for j in i:
+ mem.append (j)
+
+ return mem[1:]
diff --git a/tools/trace/tinter/tinter.py b/tools/trace/tinter/tinter.py
index 4d576ace..1491f6a8 100644
--- a/tools/trace/tinter/tinter.py
+++ b/tools/trace/tinter/tinter.py
@@ -15,7 +15,7 @@ class TInter:
self.__events = None
self.__outfile = outfile
self.__file = None
- self.__prgm = prgm
+ self.__host = THost(prgm)
def __events_get (self):
infile = open (self.__infile, 'r')
@@ -30,13 +30,13 @@ class TInter:
if cmd < len(events):
e = events[cmd]
string = e.string_get()
- vals = [ ]
+ vals = [ ]
for i in range (0, e.param_nb()):
p = e.param_get(i)
size = p.length()
vals.append (get_size (memory, size))
memory = memory[size:]
- string = string % tuple (vals)
+ string = string % tuple (vals)
if self.__file == None:
print string[1:len(string)-1]
@@ -49,9 +49,8 @@ class TInter:
def __dump (self, val):
print "Dump trace ", val
- host = THost(self.__prgm)
- host.dump_memory (val)
- memory = host.get_trace ()
+ self.__host.dump_memory (val)
+ memory = self.__host.get_trace ()
events = self.__events_get ()
if self.__outfile != None:
@@ -65,23 +64,21 @@ class TInter:
self.__file.close ()
def available_traces (self):
- host = THost(self.__prgm)
- traces = host.trace_list()
+ traces = self.__host.trace_list()
print "Traces available "
for i in traces:
print i
def trace_print (self, trace_num = None):
events = self.__events_get ()
- host = THost(self.__prgm)
- if trace_num:
- traces = host.trace_list()
+ if trace_num != None:
+ traces = self.__host.trace_list()
if traces.count (trace_num) >= 1:
self.__dump (trace_num)
else:
print "Trace not available."
else:
- traces = host.trace_list()
+ traces = self.__host.trace_list()
val = max(traces)
self.__dump (val)
diff --git a/tools/trace/trace.py b/tools/trace/trace.py
index b4c095a5..b4010a25 100644
--- a/tools/trace/trace.py
+++ b/tools/trace/trace.py
@@ -34,7 +34,7 @@ elif options.type == "inter":
inter = TInter (options.infile, options.outfile, args[0])
if options.list_trace:
inter.available_traces ()
- elif options.trace:
+ elif options.trace != None:
inter.trace_print (options.trace)
else:
inter.trace_print()