Subversion Repositories freemyipod

Rev

Rev 177 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 178
Line 323... Line 323...
323
        except IOError:
323
        except IOError:
324
            raise ArgumentError("File not readable. Does it exist?")
324
            raise ArgumentError("File not readable. Does it exist?")
325
        self.logger.info("Writing file '"+filename+"' to memory at "+self._hex(addr)+"...")
325
        self.logger.info("Writing file '"+filename+"' to memory at "+self._hex(addr)+"...")
326
        with f:
326
        with f:
327
            self.embios.write(addr, f.read())
327
            self.embios.write(addr, f.read())
-
 
328
        f.close()
328
        self.logger.info("done\n")
329
        self.logger.info("done\n")
329
    
330
    
330
    @command
331
    @command
331
    def downloadfile(self, addr, size, filename):
332
    def downloadfile(self, addr, size, filename):
332
        """
333
        """
Line 342... Line 343...
342
        except IOError:
343
        except IOError:
343
            raise ArgumentError("Can not open file for write!")
344
            raise ArgumentError("Can not open file for write!")
344
        self.logger.info("Reading data from address "+self._hex(addr)+" with the size "+self._hex(size)+" to '"+filename+"'...")
345
        self.logger.info("Reading data from address "+self._hex(addr)+" with the size "+self._hex(size)+" to '"+filename+"'...")
345
        with f:
346
        with f:
346
            f.write(self.embios.read(addr, size))
347
            f.write(self.embios.read(addr, size))
-
 
348
        f.close()
347
        self.logger.info("done\n")
349
        self.logger.info("done\n")
348
 
350
 
349
    @command
351
    @command
350
    def uploadint(self, addr, integer):
352
    def uploadint(self, addr, integer):
351
        """
353
        """
Line 356... Line 358...
356
        addr = self._hexint(addr)
358
        addr = self._hexint(addr)
357
        integer = self._hexint(integer)
359
        integer = self._hexint(integer)
358
        if integer > 0xFFFFFFFF:
360
        if integer > 0xFFFFFFFF:
359
            raise ArgumentError("Specified integer too long")
361
            raise ArgumentError("Specified integer too long")
360
        data = chr(integer)
362
        data = chr(integer)
361
        self.embios.writemem(addr, data)
363
        self.embios.write(addr, data)
362
        self.logger.info("Integer '"+self._hex(integer)+"' written successfully to "+self._hex(addr))
364
        self.logger.info("Integer '"+self._hex(integer)+"' written successfully to "+self._hex(addr))
363
 
365
 
364
    @command
366
    @command
365
    def downloadint(self, addr):
367
    def downloadint(self, addr):
366
        """
368
        """
367
            Downloads a single integer from the device and prints it to the console window
369
            Downloads a single integer from the device and prints it to the console window
368
            <offset>: the address to download the integer from
370
            <offset>: the address to download the integer from
369
        """
371
        """
370
        addr = self._hexint(addr)
372
        addr = self._hexint(addr)
371
        data = self.embios.readmem(addr, 1)
373
        data = self.embios.read(addr, 1)
372
        integer = ord(data)
374
        integer = ord(data)
373
        self.logger.info("Integer '"+self._hex(integer)+"' read from address "+self._hex(addr))
375
        self.logger.info("Integer '"+self._hex(integer)+"' read from address "+self._hex(addr))
374
 
376
 
375
    @command
377
    @command
376
    def i2cread(self, bus, slave, addr, size):
378
    def i2cread(self, bus, slave, addr, size):
Line 493... Line 495...
493
        """
495
        """
494
            Locks (freezes) the scheduler
496
            Locks (freezes) the scheduler
495
        """
497
        """
496
        self.logger.info("Will now lock scheduler\n")
498
        self.logger.info("Will now lock scheduler\n")
497
        self.embios.lockscheduler()
499
        self.embios.lockscheduler()
498
 
500
    
499
    @command
501
    @command
500
    def unlockscheduler(self):
502
    def unlockscheduler(self):
501
        """
503
        """
502
            Unlocks (unfreezes) the scheduler
504
            Unlocks (unfreezes) the scheduler
503
        """
505
        """
504
        self.logger.info("Will now unlock scheduler\n")
506
        self.logger.info("Will now unlock scheduler\n")
505
        self.embios.unlockscheduler()
507
        self.embios.unlockscheduler()
506
 
508
    
507
    @command
509
    @command
508
    def suspendthread(self, threadid):
510
    def suspendthread(self, threadid):
509
        """
511
        """
510
            Suspends/resumes the thread with thread ID <threadid>
512
            Suspends/resumes the thread with thread ID <threadid>
511
        """
513
        """
Line 662... Line 664...
662
        sha1size = 0x14
664
        sha1size = 0x14
663
        self.logger.info("Generating hmac-sha1 hash from the buffer at "+self._hex(addr)+" with the size "+self._hex(size)+
665
        self.logger.info("Generating hmac-sha1 hash from the buffer at "+self._hex(addr)+" with the size "+self._hex(size)+
664
                         " and saving it to "+self._hex(destination)+" - "+self._hex(destination+sha1size)+"...")
666
                         " and saving it to "+self._hex(destination)+" - "+self._hex(destination+sha1size)+"...")
665
        self.embios.hmac_sha1(addr, size, destination)
667
        self.embios.hmac_sha1(addr, size, destination)
666
        self.logger.info("done\n")
668
        self.logger.info("done\n")
667
        data = self.embios.readmem(destination, sha1size)
669
        data = self.embios.read(destination, sha1size)
668
        hash = ord(data)
670
        hash = ord(data)
669
        self.logger.info("The generated hash is "+self._hex(hash))
671
        self.logger.info("The generated hash is "+self._hex(hash))
670
 
672
 
671
if __name__ == "__main__":
673
if __name__ == "__main__":
672
    if len(sys.argv) < 2:
674
    if len(sys.argv) < 2: