freemyipod r106 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r105‎ | r106 | r107 >
Date:11:27, 12 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
fix libembios.py
Modified paths:
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/libembios.py
@@ -421,7 +421,7 @@
422422
423423 def downloadint(self, offset, silent = 0):
424424 self.__myprint("Downloading an integer from 0x%08x..." % (offset), silent)
425 - data = self.read(offset, 0, 0)
 425+ data = self.read(offset, 4, 0, 0)
426426 self.__myprint(" done\nValue was: 0x%08x\n" % (data), silent)
427427
428428 return data
@@ -498,7 +498,7 @@
499499 response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
500500 self.__checkstatus(response)
501501
502 - readbytes, buffersize, bytesleft = struct.unpack("<III", response[:12])
 502+ readbytes, buffersize, bytesleft = struct.unpack("<III", response[4:])
503503 out_data += response[0x10:0x10+readbytes]
504504 size -= blocklen
505505
@@ -565,7 +565,7 @@
566566 response = self.__getbulk(self.handle, self.__cinep, 0x10)
567567 self.__checkstatus(response)
568568
569 - sendbytes = struct.unpack("<I", response[4:8])[0]
 569+ sendbytes = struct.unpack("<I", response[4:])[0]
570570 if sendbytes < blocklen: # not everything has been written, need to resent some stuff but wait a bit before doing so
571571 time.sleep(0.1)
572572 timeoutcounter += 1
@@ -617,7 +617,7 @@
618618 response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
619619 self.__checkstatus(response)
620620
621 - readbytes = struct.unpack("<III", response[4:8])[0]
 621+ readbytes = struct.unpack("<III", response[4:])[0]
622622 out_data += response[0x10:0x10+readbytes]
623623 size -= blocklen
624624
@@ -749,10 +749,10 @@
750750 response = self.__getbulk(self.handle, self.__cinep, 0x10)
751751 self.__checkstatus(response)
752752
753 - if (struct.unpack("<i", response[4:8]) < 0):
754 - self.__myprint(" failed, error code: 0x%x" % (struct.unpack("<i", response[4:8])), silent)
 753+ if (struct.unpack("<i", response[4:8])[0] < 0):
 754+ self.__myprint(" failed, error code: 0x%x" % (struct.unpack("<i", response[4:8])[0]), silent)
755755 else:
756 - self.__myprint(" done\n, thread ID: 0x%x" % (struct.unpack("<I", response[4:8])), silent)
 756+ self.__myprint(" done\n, thread ID: 0x%x" % (struct.unpack("<I", response[4:8])[0]), silent)
757757
758758
759759 def getprocinfo(self, silent = 0):
@@ -770,7 +770,7 @@
771771 while ptr < len(processinfo):
772772 retval.append({})
773773
774 - retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:])[0]
 774+ retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:])
775775 ptr += 16 * 0x4
776776 retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:])[0]
777777 ptr += 1 * 0x4
@@ -860,11 +860,11 @@
861861
862862 # reading loop
863863 while (offset < size):
864 - self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 15, offset, size, 0))
865 - response = self.__getbulk(self.handle, self.__cinep, size + 0x10)
 864+ self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 15, offset, blocklen, 0))
 865+ response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
866866 self.__checkstatus(response)
867867
868 - size = struct.unpack("<I", response[8:12])[0]
 868+ size = struct.unpack("<I", response[8:])[0]
869869
870870 if size <= offset + blocklen:
871871 procinfo += response[0x10:0x10 + size]
@@ -901,9 +901,9 @@
902902 response = self.__getbulk(self.handle, self.__cinep, 0x10)
903903 self.__checkstatus(response)
904904
905 - self.__myprint(" done\n execimage() return code: 0x%08x\n" % struct.unpack("<I", response[4:8]), silent)
 905+ self.__myprint(" done\n execimage() return code: 0x%08x\n" % struct.unpack("<I", response[4:])[0], silent)
906906
907 - return struct.unpack("<I", response[4:8])
 907+ return struct.unpack("<I", response[4:])[0]
908908
909909
910910 #=====================================================================================