freemyipod r516 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r515‎ | r516 | r517 >
Date:01:21, 5 February 2011
Author:farthen
Status:new
Tags:
Comment:
emcore tools: Fix createthread. Fix execfirmware. emcore.py: Make the strings more readable
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)
  • /emcore/trunk/tools/libemcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -51,9 +51,9 @@
5252 self.seen = seen
5353 def __str__(self):
5454 if self.seen:
55 - return "Expected " + str(self.expected) + " but saw " + str(self.seen)
 55+ return "Expected %s but got %s" % (self.expected, self.seen)
5656 else:
57 - return "Expected " + str(self.expected) + ", but saw something else"
 57+ return "Expected %s, but saw something else" % self.expected
5858
5959
6060 def usage(errormsg=None, specific=False, docstring=True):
@@ -155,7 +155,7 @@
156156 except TypeError, e:
157157 # Only act on TypeErrors for the function we called, not on TypeErrors raised by another function.
158158 if str(e).split(" ", 1)[0] == func + "()":
159 - self.logger.error(usage("Argument Error in '" + func + "': Wrong argument count", specific=func) + "\n")
 159+ self.logger.error(usage("Argument Error in '%s': Wrong argument count" % func, specific=func))
160160 else:
161161 raise
162162 except libemcore.usb.core.USBError:
@@ -181,7 +181,7 @@
182182 return True
183183 elif something.lower() in falselist:
184184 return False
185 - raise ArgumentTypeError("bool", "'"+str(something)+"'")
 185+ raise ArgumentTypeError("bool", "'%s'" % something)
186186
187187 @staticmethod
188188 def _hexint(something):
@@ -196,16 +196,12 @@
197197 try:
198198 return int(something, 16)
199199 except ValueError:
200 - raise ArgumentTypeError("hexadecimal coded integer", "'"+str(something)+"'")
 200+ raise ArgumentTypeError("hexadecimal coded integer", "'%s'" % something)
201201 elif something is None:
202202 return None
203203 else:
204 - raise ArgumentTypeError("hexadecimal coded integer", "'"+str(something)+"'")
 204+ raise ArgumentTypeError("hexadecimal coded integer", "'%s'" % something)
205205
206 - @staticmethod
207 - def _hex(integer):
208 - return "0x%x" % integer
209 -
210206 @command
211207 def help(self):
212208 """ Displays this help """
@@ -219,26 +215,26 @@
220216 """
221217 if infotype == "version":
222218 hwtype = gethwname(self.emcore.lib.dev.hwtypeid)
223 - self.logger.info("Connected to " + \
224 - libemcoredata.swtypes[self.emcore.lib.dev.swtypeid] + \
225 - " v" + str(self.emcore.lib.dev.version.majorv) + \
226 - "." + str(self.emcore.lib.dev.version.minorv) + \
227 - "." + str(self.emcore.lib.dev.version.patchv) + \
228 - " r" + str(self.emcore.lib.dev.version.revision) + \
229 - " running on " + hwtype + "\n")
 219+ self.logger.info("Connected to %s v%d.%d.%d r%d running on %s\n" % (
 220+ libemcoredata.swtypes[self.emcore.lib.dev.swtypeid],
 221+ self.emcore.lib.dev.version.majorv,
 222+ self.emcore.lib.dev.version.minorv,
 223+ self.emcore.lib.dev.version.patchv,
 224+ self.emcore.lib.dev.version.revision,
 225+ hwtype))
230226
231227 elif infotype == "packetsize":
232 - self.logger.info("Maximum packet sizes: \n command out: " + str(self.emcore.lib.dev.packetsizelimit.cout) + \
233 - "\n command in: " + str(self.emcore.lib.dev.packetsizelimit.cin) + \
234 - "\n data in: " + str(self.emcore.lib.dev.packetsizelimit.din) + \
235 - "\n data out: " + str(self.emcore.lib.dev.packetsizelimit.dout)+ "\n")
 228+ self.logger.info("Maximum packet sizes:\n")
 229+ self.logger.info("command out: %d\n" % self.emcore.lib.dev.packetsizelimit.cout, 4)
 230+ self.logger.info("command in: %d\n" % self.emcore.lib.dev.packetsizelimit.cin, 4)
 231+ self.logger.info("data out: %d\n" % self.emcore.lib.dev.packetsizelimit.dout, 4)
 232+ self.logger.info("data in: %d\n" % self.emcore.lib.dev.packetsizelimit.din, 4)
236233
237234 elif infotype == "usermemrange":
238235 resp = self.emcore.getusermemrange()
239 - self.logger.info("The user memory range is " + \
240 - self._hex(self.emcore.lib.dev.usermem.lower) + \
241 - " - " + \
242 - self._hex(self.emcore.lib.dev.usermem.upper - 1) + "\n")
 236+ self.logger.info("The user memory range is 0x%X - 0x%X" % (
 237+ self.emcore.lib.dev.usermem.lower,
 238+ self.emcore.lib.dev.usermem.upper - 1))
243239
244240 else:
245241 raise ArgumentTypeError("one out of 'version', 'packetsize', 'usermemrange'", infotype)
@@ -280,10 +276,9 @@
281277 except IOError:
282278 raise ArgumentError("File not readable. Does it exist?")
283279 if addr is not None:
284 - self.logger.info("Writing file '" + filename + \
285 - "' to memory at " + self._hex(addr) + "...\n")
 280+ self.logger.info("Writing file '%s' to memory at 0x%X...\n" % (filename, addr))
286281 else:
287 - self.logger.info("Writing file '" + filename + " to an allocated memory region...\n")
 282+ self.logger.info("Writing file '%s' to an allocated memory region...\n" % filename)
288283 with f:
289284 if addr is not None:
290285 self.emcore.write(addr, f.read())
@@ -291,7 +286,7 @@
292287 addr = self.emcore.upload(f.read())
293288 size = f.tell()
294289 f.close()
295 - self.logger.info("Done uploading " + str(size) + " bytes to 0x" + self._hex(addr) + "\n")
 290+ self.logger.info("Done uploading %d bytes to 0x%X\n" % (size, addr))
296291 return addr, size
297292
298293 @command
@@ -308,9 +303,8 @@
309304 f = open(filename, 'wb')
310305 except IOError:
311306 raise ArgumentError("Can not open file for write!")
312 - self.logger.info("Reading data from address " + self._hex(addr) + \
313 - " with the size " + self._hex(size) + \
314 - " to '"+filename+"'...")
 307+ self.logger.info("Reading data from address 0x%X with the size 0x%X to '%s'..." %
 308+ (addr, size, filename))
315309 with f:
316310 f.write(self.emcore.read(addr, size))
317311 f.close()
@@ -329,8 +323,7 @@
330324 raise ArgumentError("Specified integer too long")
331325 data = struct.pack("I", integer)
332326 self.emcore.write(addr, data)
333 - self.logger.info("Integer '" + self._hex(integer) + \
334 - "' written successfully to " + self._hex(addr) + "\n")
 327+ self.logger.info("Integer '0x%X' written successfully to 0x%X\n" % (integer, addr))
335328
336329 @command
337330 def downloadint(self, addr):
@@ -341,8 +334,7 @@
342335 addr = self._hexint(addr)
343336 data = self.emcore.read(addr, 4)
344337 integer = struct.unpack("I", data)[0]
345 - self.logger.info("Integer '" + self._hex(integer) + \
346 - "' read from address " + self._hex(addr) + "\n")
 338+ self.logger.info("Read '0x%X' from address 0x%X\n" % (integer, addr))
347339
348340 @command
349341 def i2cread(self, bus, slave, addr, size):
@@ -402,7 +394,7 @@
403395 for word in args:
404396 text += word + " "
405397 text = text[:-1]
406 - self.logger.info("Writing '"+ text +"' to the usb console\n")
 398+ self.logger.info("Writing '%s' to the usb console\n" % text)
407399 self.emcore.usbcwrite(text)
408400
409401 @command
@@ -428,8 +420,7 @@
429421 for word in args:
430422 text += word + " "
431423 text = text[:-1]
432 - self.logger.info("Writing '" + text + \
433 - "' to the device consoles identified with " + self._hex(bitmask) + "\n")
 424+ self.logger.info("Writing '%s' to the device consoles identified with 0x%X\n" % (text, bitmask))
434425 self.emcore.cwrite(text, bitmask)
435426
436427 @command
@@ -439,8 +430,7 @@
440431 <bitmask>: the bitmask of the consoles to be flushed
441432 """
442433 bitmask = self._hexint(bitmask)
443 - self.logger.info("Flushing consoles identified with the bitmask " + \
444 - self._hex(bitmask) + "\n")
 434+ self.logger.info("Flushing consoles identified with the bitmask 0x%X\n" % bitmask)
445435 self.emcore.cflush(bitmask)
446436
447437 @command
@@ -463,16 +453,16 @@
464454 % (len(threads), cpuload * 100, coreload * 100, threadload * 100))
465455 self.logger.info("Thread dump:\n")
466456 for thread in threads:
467 - self.logger.info(thread.name+":\n", 2)
468 - self.logger.info("Threadstruct address: " + self._hex(thread.addr)+"\n", 4)
469 - self.logger.info("Thread type: " + str(thread.thread_type)+"\n", 4)
470 - self.logger.info("Thread state: " + str(thread.state)+"\n", 4)
471 - self.logger.info("Block type: " + str(thread.block_type)+"\n", 4)
472 - self.logger.info("Blocked by: " + self._hex(thread.blocked_by)+"\n", 4)
473 - self.logger.info("Priority: " + str(thread.priority)+"/255\n", 4)
 457+ self.logger.info("%s:\n" % thread.name, 2)
 458+ self.logger.info("Threadstruct address: 0x%X\n" % thread.addr, 4)
 459+ self.logger.info("Thread type: %s\n" % thread.thread_type, 4)
 460+ self.logger.info("Thread state: %s\n" % thread.state, 4)
 461+ self.logger.info("Block type: %s\n" % thread.block_type, 4)
 462+ self.logger.info("Blocked by: 0x%X\n" % thread.blocked_by, 4)
 463+ self.logger.info("Priority: %d/255\n" % thread.priority, 4)
474464 self.logger.info("Current CPU load: %.1f%%\n" % ((thread.cpuload * 100) / 255.), 4)
475 - self.logger.info("CPU time (total): "+str(datetime.timedelta(microseconds = thread.cputime_total))+"\n", 4)
476 - self.logger.info("Stack address: " + self._hex(thread.stack)+"\n", 4)
 465+ self.logger.info("CPU time (total): %s\n" % datetime.timedelta(microseconds = thread.cputime_total), 4)
 466+ self.logger.info("Stack address: 0x%X\n" % thread.stack, 4)
477467 self.logger.info("Registers:\n", 4)
478468 for registerrange in range(4):
479469 self.logger.info(" ")
@@ -500,57 +490,54 @@
501491 self.emcore.unlockscheduler()
502492
503493 @command
504 - def suspendthread(self, threadid):
 494+ def suspendthread(self, threadaddr):
505495 """
506 - Suspends/resumes the thread with thread ID <threadid>
 496+ Suspends the thread with the thread address <threadaddr>
507497 """
508 - threadid = self._hexint(threadid)
509 - self.logger.info("Suspending the thread with the threadid "+self._hex(threadid)+"\n")
510 - self.emcore.suspendthread(threadid)
 498+ threadaddr = self._hexint(threadaddr)
 499+ self.logger.info("Suspending the thread with the threadaddr 0x%X\n" % threadaddr)
 500+ self.emcore.suspendthread(threadaddr)
511501
512502 @command
513 - def resumethread(self, threadid):
 503+ def resumethread(self, threadaddr):
514504 """
515 - Resumes the thread with thread ID <threadid>
 505+ Resumes the thread with the thread address <threadaddr>
516506 """
517 - threadid = self._hexint(threadid)
518 - self.logger.info("Resuming the thread with the threadid "+self._hex(threadid)+"\n")
519 - self.emcore.resumethread(threadid)
 507+ threadaddr = self._hexint(threadaddr)
 508+ self.logger.info("Resuming the thread with the threadaddr 0x%X\n" % threadaddr)
 509+ self.emcore.resumethread(threadaddr)
520510
521511 @command
522 - def killthread(self, threadid):
 512+ def killthread(self, threadaddr):
523513 """
524 - Kills the thread with thread ID <threadid>
 514+ Kills the thread with the thread address <threadaddr>
525515 """
526 - threadid = self._hexint(threadid)
527 - self.logger.info("Killing the thread with the threadid " + self._hex(threadid) + "\n")
528 - self.emcore.killthread(threadid)
 516+ threadaddr = self._hexint(threadaddr)
 517+ self.logger.info("Killing the thread with the threadaddr 0x%X\n" % threadaddr)
 518+ self.emcore.killthread(threadaddr)
529519
530520 @command
531521 def createthread(self, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state):
532522 """
533 - Creates a new thread and returns its thread ID
 523+ Creates a new thread and returns its thread pointer
534524 <namepointer>: a pointer to the thread's name
535525 <entrypoint>: a pointer to the entrypoint of the thread
536526 <stackpointer>: a pointer to the stack of the thread
537527 <stacksize>: the size of the thread's stack
538 - <type>: the thread type, vaild are: 0 => user thread, 1 => system thread
 528+ <threadtype>: the thread type, vaild are: 0 => user thread, 1 => system thread
539529 <priority>: the priority of the thread, from 1 to 255
540530 <state>: the thread's initial state, valid are: 1 => ready, 0 => suspended
541531 """
542532 nameptr = self._hexint(nameptr)
543533 entrypoint = self._hexint(entrypoint)
544 - stackpointer = self._hexint(stackpointer)
 534+ stackptr = self._hexint(stackptr)
545535 stacksize = self._hexint(stacksize)
546536 priority = self._hexint(priority)
547 - data = self.emcore.createthread(nameptr, entrypoint, stackptr, stacksize, type, priority, state)
 537+ data = self.emcore.createthread(nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state)
548538 name = self.emcore.readstring(nameptr)
549 - self.logger.info("Created a thread with the threadid " + data.id + \
550 - ", the name \"" + name + "\"" + \
551 - ", the entrypoint at " + self._hex(entrypoint) + \
552 - ", the stack at " + self._hex(stackpointer) + \
553 - " with a size of " + self._hex(stacksize) + \
554 - " and a priority of " + self._hex(priority) + "\n")
 539+ self.logger.info("Created a thread with the thread pointer 0x%X, the name \"%s\", the entrypoint at 0x%X," \
 540+ "the stack at 0x%X with a size of 0x%X and a priority of %d/255\n" %
 541+ (data.threadptr, name, entrypoint, stackptr, stacksize, priority))
555542
556543 @command
557544 def run(self, filename):
@@ -564,7 +551,7 @@
565552 raise ArgumentError("File not readable. Does it exist?")
566553 with f:
567554 data = self.emcore.run(f.read())
568 - self.logger.info("Executed emCORE application as thread " + self._hex(data.thread) + "\n")
 555+ self.logger.info("Executed emCORE application as thread 0x%X\n" % data.thread)
569556
570557 @command
571558 def execimage(self, addr):
@@ -572,7 +559,7 @@
573560 Executes the emCORE application at <addr>.
574561 """
575562 addr = self._hexint(addr)
576 - self.logger.info("Starting emCORE app at "+self._hex(addr)+"\n")
 563+ self.logger.info("Starting emCORE app at 0x%X\n" % addr)
577564 self.emcore.execimage(addr)
578565
579566 @command
@@ -594,8 +581,8 @@
595582 addr_flash = self._hexint(addr_flash)
596583 addr_mem = self._hexint(addr_mem)
597584 size = self._hexint(size)
598 - self.logger.info("Dumping boot flash addresses "+self._hex(addr_flash)+" - "+
599 - hex(addr_flash+size)+" to "+self._hex(addr_mem)+" - "+self._hex(addr_mem+size)+"\n")
 585+ self.logger.info("Dumping boot flash from 0x%X - 0x%X to 0x%X - 0x%X\n" %
 586+ (addr_flash, addr_flash + size, addr_mem, addr_mem + size))
600587 self.emcore.bootflashread(addr_mem, addr_flash, size)
601588
602589 @command
@@ -612,8 +599,8 @@
613600 addr_mem = self._hexint(addr_mem)
614601 size = self._hexint(size)
615602 force = self._bool(force)
616 - self.logger.warn("Writing boot flash from the memory in "+self._hex(addr_mem)+" - "+
617 - hex(addr_mem+size)+" to "+self._hex(addr_flash)+" - "+self._hex(addr_flash+size)+"\n")
 603+ self.logger.warn("Writing boot flash from the memory in 0x%X - 0x%X to 0x%X - 0x%X\n" %
 604+ (addr_mem, addr_mem + size, addr_flash, addr_flash + size))
618605 if force == False:
619606 self.logger.warn("If this was not what you intended press Ctrl-C NOW")
620607 for i in range(10):
@@ -637,8 +624,9 @@
638625 """
639626 Moves the firmware at <addr> with <size> to <targetaddr> and executes it
640627 """
 628+ targetaddr = self._hexint(targetaddr)
641629 addr = self._hexint(addr)
642 - self.logger.info("Running firmware at "+self._hex(targetaddr)+". Bye.\n")
 630+ self.logger.info("Running firmware at 0x%X. Bye.\n" % targetaddr)
643631 self.emcore.execfirmware(targetaddr, addr, size)
644632
645633 @command
@@ -679,14 +667,13 @@
680668 size = self._hexint(size)
681669 destination = self._hexint(destination)
682670 sha1size = 0x14
683 - self.logger.info("Generating hmac-sha1 hash from the buffer at " + self._hex(addr) + \
684 - " with the size " + self._hex(size) + " and saving it to " + \
685 - self._hex(destination) + " - " + self._hex(destination+sha1size) + "...")
 671+ self.logger.info("Generating hmac-sha1 hash from the buffer at 0x%X with the size 0x%X and saving it to 0x%X - 0x%X\n" %
 672+ (addr, size, destination, destination + sha1size))
686673 self.emcore.hmac_sha1(addr, size, destination)
687674 self.logger.info("done\n")
688675 data = self.emcore.read(destination, sha1size)
689676 hash = ord(data)
690 - self.logger.info("The generated hash is "+self._hex(hash)+"\n")
 677+ self.logger.info("The generated hash is 0x%X\n" % hash)
691678
692679 @command
693680 def ipodnano2g_getnandinfo(self):
@@ -695,11 +682,11 @@
696683 Gathers some information about the NAND chip used
697684 """
698685 data = self.emcore.ipodnano2g_getnandinfo()
699 - self.logger.info("NAND chip type: " + self._hex(data["type"])+"\n")
700 - self.logger.info("Number of banks: " + str(data["banks"])+"\n")
701 - self.logger.info("Number of blocks: " + str(data["blocks"])+"\n")
702 - self.logger.info("Number of user blocks: " + str(data["userblocks"])+"\n")
703 - self.logger.info("Pages per block: " + str(data["pagesperblock"])+"\n")
 686+ self.logger.info("NAND chip type: 0x%X\n" % data["type"])
 687+ self.logger.info("Number of banks: %d\n" % data["banks"])
 688+ self.logger.info("Number of blocks: %d\n" % data["blocks"])
 689+ self.logger.info("Number of user blocks: %d\n" % data["userblocks"])
 690+ self.logger.info("Pages per block: %d\n" % data["pagesperblock"])
704691
705692 @command
706693 def ipodnano2g_nandread(self, addr, start, count, doecc=True, checkempty=True):
@@ -717,8 +704,8 @@
718705 count = self._hexint(count)
719706 doecc = self._bool(doecc)
720707 checkempty = self._bool(checkempty)
721 - self.logger.info("Reading " + self._hex(count) + " NAND pages starting at " + \
722 - self._hex(start) + " to " + self._hex(addr) + "...")
 708+ self.logger.info("Reading 0x%X NAND pages starting at 0x%X to memory at 0x%X..." %
 709+ (count, start, addr))
723710 self.emcore.ipodnano2g_nandread(addr, start, count, doecc, checkempty)
724711 self.logger.info("done\n")
725712
@@ -736,8 +723,8 @@
737724 start = self._hexint(start)
738725 count = self._hexint(count)
739726 doecc = self._bool(doecc)
740 - self.logger.info("Writing " + self._hex(count) + " NAND pages starting at " + \
741 - self._hex(start) + " from " + self._hex(addr) + "...")
 727+ self.logger.info("Writing 0x%X NAND pages starting at 0x%X from memory at 0x%X..." %
 728+ (count, start, addr))
742729 self.emcore.ipodnano2g_nandwrite(addr, start, count, doecc)
743730 self.logger.info("done\n")
744731
@@ -753,8 +740,8 @@
754741 addr = self._hexint(addr)
755742 start = self._hexint(start)
756743 count = self._hexint(count)
757 - self.logger.info("Erasing " + self._hex(count) + " NAND blocks starting at " + \
758 - self._hex(start) + " and logging to " + self._hex(addr) + "...")
 744+ self.logger.info("Erasing 0x%X NAND pages starting at 0x%X and logging to 0x%X..." %
 745+ (count, start, addr))
759746 self.emcore.ipodnano2g_nanderase(addr, start, count)
760747 self.logger.info("done\n")
761748
@@ -774,11 +761,11 @@
775762 statusfile = open(filenameprefix+"_status.bin", 'wb')
776763 except IOError:
777764 raise ArgumentError("Can not open file for writing!")
778 - infofile.write("NAND chip type: " + self._hex(info["type"]) + "\r\n")
779 - infofile.write("Number of banks: " + str(info["banks"]) + "\r\n")
780 - infofile.write("Number of blocks: " + str(info["blocks"]) + "\r\n")
781 - infofile.write("Number of user blocks: "+ str(info["userblocks"]) + "\r\n")
782 - infofile.write("Pages per block: " + str(info["pagesperblock"]) + "\r\n")
 765+ infofile.write("NAND chip type: 0x%X\r\n" % info["type"])
 766+ infofile.write("Number of banks: %d\r\n" % info["banks"])
 767+ infofile.write("Number of blocks: %d\r\n" % info["blocks"])
 768+ infofile.write("Number of user blocks: %d\r\n" % info["userblocks"])
 769+ infofile.write("Pages per block: %d\r\n" % info["pagesperblock"])
783770 for i in range(info["banks"] * info["blocks"] * info["pagesperblock"] / 8192):
784771 self.logger.info(".")
785772 self.emcore.ipodnano2g_nandread(0x08000000, i * 8192, 8192, 1, 1)
@@ -844,11 +831,11 @@
845832 """
846833 volume = self._hexint(volume)
847834 data = self.emcore.storage_get_info(volume)
848 - self.logger.info("Sector size: "+str(data["sectorsize"])+"\n")
849 - self.logger.info("Number of sectors: "+str(data["numsectors"])+"\n")
850 - self.logger.info("Vendor: "+data["vendor"]+"\n")
851 - self.logger.info("Product: "+data["product"]+"\n")
852 - self.logger.info("Revision: "+data["revision"]+"\n")
 835+ self.logger.info("Sector size: %d\n" % data["sectorsize"])
 836+ self.logger.info("Number of sectors: %d\n" % data["numsectors"])
 837+ self.logger.info("Vendor: %s\n" % data["vendor"])
 838+ self.logger.info("Product: %s\n" % data["product"])
 839+ self.logger.info("Revision: %s\n" % data["revision"])
853840
854841 @command
855842 def readrawstorage(self, volume, sector, count, addr):
@@ -961,7 +948,7 @@
962949 """
963950 Creates a directory with the name <dirname>
964951 """
965 - self.logger.info("Creating directory " + dirname + "...")
 952+ self.logger.info("Creating directory %s..." % dirname)
966953 self.emcore.dir_create(dirname)
967954 self.logger.info(" done\n")
968955
@@ -970,7 +957,7 @@
971958 """
972959 Removes an empty directory with the name <dirname>
973960 """
974 - self.logger.info("Removing directory " + dirname + "...")
 961+ self.logger.info("Removing directory %s..." % dirname)
975962 self.emcore.dir_remove(dirname)
976963 self.logger.info(" done\n")
977964
@@ -979,7 +966,7 @@
980967 """
981968 Removes a file with the name <filename>
982969 """
983 - self.logger.info("Removing file " + filename + "...")
 970+ self.logger.info("Removing file %s..." % filename)
984971 self.emcore.file_unlink(filename)
985972 self.logger.info(" done\n")
986973
@@ -1006,7 +993,7 @@
1007994 """
1008995 Renames or moves file or directory <oldname> to <newname>
1009996 """
1010 - self.logger.info("Renaming " + oldname + " to " + newname + "...")
 997+ self.logger.info("Renaming %s to %s..." % (oldname, newname))
1011998 self.emcore.file_rename(oldname, newname)
1012999 self.logger.info(" done\n")
10131000
@@ -1036,7 +1023,7 @@
10371024 buffer = self._hexint(buffer)
10381025 malloc = False
10391026 try:
1040 - self.logger.info("Downloading file " + remotename + " to " + localname + "...")
 1027+ self.logger.info("Downloading file %s to %s..." % (remotename, localname))
10411028 while size > 0:
10421029 bytes = self.emcore.file_read(fd, buffsize, buffer).rc
10431030 f.write(self.emcore.read(buffer, bytes))
@@ -1108,7 +1095,7 @@
11091096 buffer = self._hexint(buffer)
11101097 malloc = False
11111098 try:
1112 - self.logger.info("Uploading file " + localname + " to " + remotename + "...")
 1099+ self.logger.info("Uploading file %s to %s..." % (localname, remotename))
11131100 fd = self.emcore.file_open(remotename, 0x15)
11141101 try:
11151102 while True:
@@ -1167,7 +1154,7 @@
11681155 [path]: the path which is listed
11691156 """
11701157 handle = self.emcore.dir_open(path)
1171 - self.logger.info("Directory listing of " + path + ":\n")
 1158+ self.logger.info("Directory listing of %s:\n" % path)
11721159 while True:
11731160 try:
11741161 entry = self.emcore.dir_read(handle)
Index: emcore/trunk/tools/libemcore.py
@@ -438,9 +438,9 @@
439439 state = 1
440440 else:
441441 raise ArgumentError("State must be either 'ready' or 'suspended'")
442 - resp = self.lib.monitorcommand(struct.pack("IIIIIIII", 19, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state), "III", (id, None, None))
443 - if resp.id < 0:
444 - raise DeviceError("The device returned the error code "+str(resp.id))
 442+ resp = self.lib.monitorcommand(struct.pack("IIIIIIII", 19, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state), "III", ("threadptr", None, None))
 443+ if resp.threadptr < 0:
 444+ raise DeviceError("The device returned the error code "+str(resp.threadptr))
445445 return resp
446446
447447 @command()