freemyipod r774 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r773‎ | r774 | r775 >
Date:22:07, 12 October 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE python tools: Update mutex struct, increase default timeout and add up/downloadbyte functions
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)
  • /emcore/trunk/tools/libemcore.py (modified) (history)
  • /emcore/trunk/tools/libemcoredata.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -19,7 +19,7 @@
2020 # You should have received a copy of the GNU General Public License
2121 # along with emCORE. If not, see <http://www.gnu.org/licenses/>.
2222 #
23 -#
 23+#
2424
2525 """
2626 Command line interface to communicate with emCORE devices.
@@ -311,6 +311,32 @@
312312 sys.stdout.write("\n")
313313
314314 @command
 315+ def uploadbyte(self, addr, byte):
 316+ """
 317+ Uploads a single byte to the device
 318+ <addr>: the address to upload the byte to
 319+ <byte>: the byte to upload
 320+ """
 321+ addr = to_int(addr)
 322+ byte = to_int(byte)
 323+ if byte > 0xFF:
 324+ raise ArgumentError("Specified integer too long")
 325+ data = struct.pack("B", byte)
 326+ self.emcore.write(addr, data)
 327+ self.logger.info("Byte '0x%X' written successfully to 0x%X\n" % (byte, addr))
 328+
 329+ @command
 330+ def downloadbyte(self, addr):
 331+ """
 332+ Downloads a single byte from the device and prints it to the console window
 333+ <addr>: the address to download the byte from
 334+ """
 335+ addr = to_int(addr)
 336+ data = self.emcore.read(addr, 1)
 337+ byte = struct.unpack("B", data)[0]
 338+ self.logger.info("Read '0x%X' from address 0x%X\n" % (byte, addr))
 339+
 340+ @command
315341 def uploadint(self, addr, integer):
316342 """
317343 Uploads a single integer to the device
@@ -383,7 +409,7 @@
384410 while True:
385411 resp = self.emcore.usbcread()
386412 self.logger.write(resp.data, target = "stdout")
387 - time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
 413+# time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
388414
389415 @command
390416 def writeusbconsole(self, *args):
Index: emcore/trunk/tools/libemcoredata.py
@@ -86,6 +86,7 @@
8787 class mutex(ExtendedCStruct):
8888 _fields_ = [("owner", c_uint32),
8989 ("waiters", c_uint32),
 90+ ("owned_next", c_uint32),
9091 ("count", c_int32),
9192 ]
9293
Index: emcore/trunk/tools/libemcore.py
@@ -1015,7 +1015,7 @@
10161016 self.logger.debug("Initializing Dev object\n")
10171017
10181018 self.interface = 0
1019 - self.timeout = 100
 1019+ self.timeout = 1000
10201020
10211021 self.connect()
10221022 self.findEndpoints()