freemyipod r215 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r214‎ | r215 | r216 >
Date:17:30, 8 October 2010
Author:theseven
Status:new
Tags:
Comment:
Some embios.py/libembios fixes: correct device console command IDs and fix some crashes
Modified paths:
  • /embios/trunk/tools/embios.py (modified) (history)
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/embios.py
@@ -26,6 +26,7 @@
2727 import inspect
2828 import re
2929 import time
 30+import struct
3031
3132 from functools import wraps
3233
@@ -387,7 +388,8 @@
388389 slave = self._hexint(slave)
389390 addr = self._hexint(addr)
390391 size = self._hexint(size)
391 - self.embios.i2cread(bus, slave, addr, size)
 392+ for i in range(size):
 393+ print("%02X: %02X" % (addr + i, struct.unpack("B", self.embios.i2cread(bus, slave, addr + i, 1))[0]))
392394
393395 @command
394396 def i2cwrite(self, bus, slave, addr, *args):
Index: embios/trunk/tools/libembios.py
@@ -233,7 +233,7 @@
234234 raise ValueError("Size must be a number between 1 and 256")
235235 if size == 256:
236236 size = 0
237 - return self.lib.monitorcommand(struct.pack("IBBBBII%ds" % size, 9, index, slaveaddr, startaddr, size, 0, 0, data), "III" % size, (None, None, None))
 237+ return self.lib.monitorcommand(struct.pack("IBBBBII%ds" % size, 9, index, slaveaddr, startaddr, size, 0, 0, data), "III", (None, None, None))
238238
239239 def usbcread(self):
240240 """ Reads one packet with the maximal cin size """
@@ -258,7 +258,7 @@
259259 identified with the specified bitmask
260260 """
261261 cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
262 - resp = self.lib.monitorcommand(struct.pack("IIII", 14, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("size", None, None))
 262+ resp = self.lib.monitorcommand(struct.pack("IIII", 13, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("size", None, None))
263263 resp.data = resp.data[size:]
264264 resp.maxsize = cin_maxsize
265265 return resp
@@ -271,7 +271,7 @@
272272 size = len(data)
273273 while len(data) > 0:
274274 writesize = min(cin_maxsize, len(data))
275 - resp = self.lib.monitorcommand(struct.pack("IIII%ds" % writesize, 13, writesize, 0, 0, data[:writesize]), "III", (None, None, None))
 275+ resp = self.lib.monitorcommand(struct.pack("IIII%ds" % writesize, 12, writesize, 0, 0, data[:writesize]), "III", (None, None, None))
276276 data = data[writesize:]
277277 return size
278278