freemyipod r452 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r451‎ | r452 | r453 >
Date:20:15, 19 January 2011
Author:theseven
Status:new
Tags:
Comment:
[lib]emcore.py: Adapt "run" command to new interface
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)
  • /emcore/trunk/tools/libemcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -564,7 +564,7 @@
565565 raise ArgumentError("File not readable. Does it exist?")
566566 with f:
567567 data = self.emcore.run(f.read())
568 - self.logger.info("Executed emCORE application \"" + data.name + "\" at address " + self._hex(data.baseaddr))
 568+ self.logger.info("Executed emCORE application as thread " + self._hex(data.thread))
569569
570570 @command
571571 def execimage(self, addr):
Index: emcore/trunk/tools/libemcore.py
@@ -484,37 +484,17 @@
485485 @command()
486486 def execimage(self, addr):
487487 """ Runs the emCORE app at 'addr' """
488 - return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("rc", None, None))
 488+ return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("thread", None, None))
489489
490490 @command()
491491 def run(self, app):
492492 """ Uploads and runs the emCORE app in the string 'app' """
493 - try:
494 - appheader = struct.unpack("<8sIIIIIIIIII", app[:48])
495 - except struct.error:
 493+ if app[:8] != "emCOexec":
496494 raise ArgumentError("The specified app is not an emCORE application")
497 - header = appheader[0]
498 - if header != "emBIexec":
499 - raise ArgumentError("The specified app is not an emCORE application")
500 - baseaddr = appheader[2]
501 - threadnameptr = appheader[8]
502 - nameptr = threadnameptr - baseaddr
503 - name = ""
504 - while True:
505 - char = app[nameptr:nameptr+1]
506 - try:
507 - if ord(char) == 0:
508 - break
509 - except TypeError:
510 - raise ArgumentError("The specified app is not an emCORE application")
511 - name += char
512 - nameptr += 1
513 - usermem = self.getusermemrange()
514 - if usermem.lower > baseaddr or usermem.upper < baseaddr + len(app):
515 - raise ArgumentError("The baseaddress of the specified emCORE application is out of range of the user memory range on the device. Are you sure that this application is compatible with your device?")
 495+ baseaddr = self.malloc(len(app))
516496 self.write(baseaddr, app)
517 - self.execimage(baseaddr)
518 - return Bunch(baseaddr=baseaddr, name=name)
 497+ result = self.execimage(baseaddr)
 498+ return Bunch(thread=result.thread)
519499
520500 @command(timeout = 5000)
521501 def bootflashread(self, memaddr, flashaddr, size):