Subversion Repositories freemyipod

Rev

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

Rev 178 Rev 215
Line 231... Line 231...
231
        size = len(data)
231
        size = len(data)
232
        if size > 256 or size < 1:
232
        if size > 256 or size < 1:
233
            raise ValueError("Size must be a number between 1 and 256")
233
            raise ValueError("Size must be a number between 1 and 256")
234
        if size == 256:
234
        if size == 256:
235
            size = 0
235
            size = 0
236
        return self.lib.monitorcommand(struct.pack("IBBBBII%ds" % size, 9, index, slaveaddr, startaddr, size, 0, 0, data), "III" % size, (None, None, None))
236
        return self.lib.monitorcommand(struct.pack("IBBBBII%ds" % size, 9, index, slaveaddr, startaddr, size, 0, 0, data), "III", (None, None, None))
237
    
237
    
238
    def usbcread(self):
238
    def usbcread(self):
239
        """ Reads one packet with the maximal cin size """
239
        """ Reads one packet with the maximal cin size """
240
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
240
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
241
        resp = self.lib.monitorcommand(struct.pack("IIII", 10, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("validsize", "buffersize", "queuesize", "data"))
241
        resp = self.lib.monitorcommand(struct.pack("IIII", 10, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("validsize", "buffersize", "queuesize", "data"))
Line 256... Line 256...
256
    def cread(self, bitmask=0x1):
256
    def cread(self, bitmask=0x1):
257
        """ Reads one packet with the maximal cin size from the device consoles
257
        """ Reads one packet with the maximal cin size from the device consoles
258
            identified with the specified bitmask
258
            identified with the specified bitmask
259
        """
259
        """
260
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
260
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
261
        resp = self.lib.monitorcommand(struct.pack("IIII", 14, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("size", None, None))
261
        resp = self.lib.monitorcommand(struct.pack("IIII", 13, cin_maxsize, 0, 0), "III%ds" % cin_maxsize, ("size", None, None))
262
        resp.data = resp.data[size:]
262
        resp.data = resp.data[size:]
263
        resp.maxsize = cin_maxsize
263
        resp.maxsize = cin_maxsize
264
        return resp
264
        return resp
265
 
265
 
266
    def cwrite(self, data, bitmask=0x1):
266
    def cwrite(self, data, bitmask=0x1):
Line 269... Line 269...
269
        """
269
        """
270
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
270
        cin_maxsize = self.lib.dev.packetsizelimit["cin"] - self.lib.headersize
271
        size = len(data)
271
        size = len(data)
272
        while len(data) > 0:
272
        while len(data) > 0:
273
            writesize = min(cin_maxsize, len(data))
273
            writesize = min(cin_maxsize, len(data))
274
            resp = self.lib.monitorcommand(struct.pack("IIII%ds" % writesize, 13, writesize, 0, 0, data[:writesize]), "III", (None, None, None))
274
            resp = self.lib.monitorcommand(struct.pack("IIII%ds" % writesize, 12, writesize, 0, 0, data[:writesize]), "III", (None, None, None))
275
            data = data[writesize:]
275
            data = data[writesize:]
276
        return size
276
        return size
277
    
277
    
278
    def cflush(self, bitmask):
278
    def cflush(self, bitmask):
279
        """ Flushes the consoles specified with 'bitmask' """
279
        """ Flushes the consoles specified with 'bitmask' """