summaryrefslogtreecommitdiff
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
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.
-rw-r--r--digital/avr/modules/flash/flash.c25
-rw-r--r--digital/avr/modules/flash/flash.h3
-rw-r--r--digital/avr/modules/flash/flash.host.c24
-rw-r--r--digital/avr/modules/flash/test/test-flash.c6
-rw-r--r--digital/avr/modules/trace/test/test-trace.c10
-rw-r--r--tools/trace/tinter/thost.py39
-rw-r--r--tools/trace/tinter/tinter.py21
-rw-r--r--tools/trace/trace.py2
8 files changed, 87 insertions, 43 deletions
diff --git a/digital/avr/modules/flash/flash.c b/digital/avr/modules/flash/flash.c
index b8f9143c..e75df80c 100644
--- a/digital/avr/modules/flash/flash.c
+++ b/digital/avr/modules/flash/flash.c
@@ -47,19 +47,30 @@ flash_log (uint8_t size, uint8_t *args)
&& (args[4] <= sizeof(buf)))
{
flash_read_array (addr, buf, args[4]);
+ proto_send4b ('a', 0, addr >> 16, addr >> 8, addr);
proto_send ('r', args[4], buf);
- error = 0;
}
- else if (size == 4)
+ case FLASH_CMD_READ_BYTE:
+ if (size == 4)
{
proto_send1b ('r', flash_read (addr));
- error = 0;
}
- else
- error = 2;
break;
- default:
- return 3;
+ case FLASH_CMD_WRITE_BYTE:
+ if (size == 5)
+ {
+ proto_send1b ('w', args[4]);
+ flash_write (addr, args[4]);
+ }
+ break;
+ case FLASH_CMD_WRITE:
+ if ((size == 5)
+ && (args[4] <= sizeof(buf)))
+ {
+ flash_write_array (addr, buf, args[4]);
+ proto_send ('w', args[4], buf);
+ }
+ break;
}
return error;
diff --git a/digital/avr/modules/flash/flash.h b/digital/avr/modules/flash/flash.h
index ff4713db..1a24d59e 100644
--- a/digital/avr/modules/flash/flash.h
+++ b/digital/avr/modules/flash/flash.h
@@ -57,6 +57,9 @@ enum
{
FLASH_CMD_INIT,
FLASH_CMD_READ,
+ FLASH_CMD_WRITE,
+ FLASH_CMD_READ_BYTE,
+ FLASH_CMD_WRITE_BYTE,
FLASH_CMD_NB
};
diff --git a/digital/avr/modules/flash/flash.host.c b/digital/avr/modules/flash/flash.host.c
index 1d984f32..9b0666bf 100644
--- a/digital/avr/modules/flash/flash.host.c
+++ b/digital/avr/modules/flash/flash.host.c
@@ -161,7 +161,7 @@ flash_read (uint32_t addr)
res = read (flash_global.file, &data, sizeof (uint8_t));
if (res == 0)
- flash_global.status = 0;
+ flash_deactivate ();
return data;
}
@@ -174,20 +174,22 @@ flash_read_array (uint32_t addr, uint8_t *buffer, uint32_t length)
{
if (flash_global.status)
{
- uint32_t nb;
- int8_t res;
- /* Set the stream to the position required. */
+ uint8_t res;
+ uint8_t deactivate = 1;
+
+ /* Set the stream to the position of address. */
res = lseek (flash_global.file, addr, SEEK_SET);
- if (res == -1)
+ if (res == addr)
{
- flash_deactivate();
- return;
- }
+ res = read (flash_global.file, buffer, length);
+ printf ("read: %d\n", res);
- nb = read (flash_global.file, buffer, length);
+ if (res == length)
+ deactivate = 0x0;
+ }
- if (nb != length)
- flash_deactivate();
+ if (deactivate == 0x1)
+ flash_deactivate ();
}
}
diff --git a/digital/avr/modules/flash/test/test-flash.c b/digital/avr/modules/flash/test/test-flash.c
index bbfcfd6a..99b12df2 100644
--- a/digital/avr/modules/flash/test/test-flash.c
+++ b/digital/avr/modules/flash/test/test-flash.c
@@ -92,7 +92,11 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
proto_send1b ('f', status);
break;
default:
- if (cmd == 'w' && size > 4)
+ if (cmd == 'l')
+ {
+ flash_log (size, args);
+ }
+ else if (cmd == 'w' && size > 4)
{
/* Write several bytes:
* - 3b: address.
diff --git a/digital/avr/modules/trace/test/test-trace.c b/digital/avr/modules/trace/test/test-trace.c
index 7938103b..a4d1b0d4 100644
--- a/digital/avr/modules/trace/test/test-trace.c
+++ b/digital/avr/modules/trace/test/test-trace.c
@@ -42,6 +42,7 @@ flood (void)
uint32_t addr;
uint32_t count;
+ uint16_t id;
uint32_t speed;
uint32_t position;
uint16_t acc;
@@ -67,9 +68,12 @@ flood (void)
arg1 = 1;
arg2 = 2;
arg3 = 3;
- TRACE (TRACE_ASSERV__RIGHT_MOTOR, speed, position, acc);
- TRACE (TRACE_ASSERV__LEFT_MOTOR, speed, position, acc);
- TRACE (TRACE_IA__IA_CMD, arg1, arg2, arg3);
+ id = TRACE_ASSERV__RIGHT_MOTOR;
+ TRACE (id, speed, position, acc);
+ id = TRACE_ASSERV__LEFT_MOTOR;
+ TRACE (id, speed, position, acc);
+ id = TRACE_IA__IA_CMD;
+ TRACE (id, arg1, arg2, arg3);
}
/* Print the end of the address. */
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()