View Single Post
Old 02-10-2007, 02:13 PM   #19
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Quote:
Originally Posted by kovidgoyal
EDIT: Looking at my code, I always sent 8bytes as the key, never 4

Hmm the screen lock code is still 4 characters in length, so this seems to be pretty pointless.
The --log-packets says 4 and the source code I have says 4...

Code:
class UnlockDevice(ShortCommand):
    """ Unlock the device """
    NUMBER = 0x106 #: Command number
    def __init__(self, key=0x312d):
        ShortCommand.__init__(self, \
        number=UnlockDevice.NUMBER, type=0x01, command=key)

class ShortCommand(Command):

    """ A L{Command} whoose data section is 4 bytes long """

    SIZE = 20 #: Packet size in bytes
    # Usually carries additional information
    command = field(start=16, fmt=DWORD)

    def __init__(self, number=0x00, type=0x00, command=0x00):
        """
        @param number: L{Command.number}
        @param type: L{Command.type}
        @param command: L{ShortCommand.command}
        """
        Command.__init__(self, ShortCommand.SIZE)
        self.number  = number
        self.type    = type
        self.length  = 4
        self.command = command
I believe the hard coded "self.length = 4" seals the deal.

Code:
        res = self.send_validated_command(SetBulkSize(size=0x028000))
        if res.code != 0:
            raise ProtocolError("Unable to set bulk size.")
        self.send_validated_command(UnlockDevice(key=0x312d))
scotty1024 is offline   Reply With Quote