Subversion Repositories freemyipod

Rev

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

Rev 227 Rev 236
Line 217... Line 217...
217
            addr += cin_maxsize
217
            addr += cin_maxsize
218
        return string
218
        return string
219
    
219
    
220
    def i2cread(self, index, slaveaddr, startaddr, size):
220
    def i2cread(self, index, slaveaddr, startaddr, size):
221
        """ Reads data from an i2c slave """
221
        """ Reads data from an i2c slave """
222
        if size > 256 or size < 1:
-
 
223
            raise ValueError("Size must be a number between 1 and 256")
-
 
224
        if size == 256:
222
        data = ""
225
            size = 0
223
        for i in range(size):
226
        resp = self.lib.monitorcommand(struct.pack("IBBBBII", 8, index, slaveaddr, startaddr, size, 0, 0), "III%ds" % size, (None, None, None, "data"))
224
            resp = self.lib.monitorcommand(struct.pack("IBBBBII", 8, index, slaveaddr, startaddr + i, 1, 0, 0), "III1s", (None, None, None, "data"))
-
 
225
            data += resp.data
227
        return resp.data
226
        return data
228
    
227
    
229
    def i2cwrite(self, index, slaveaddr, startaddr, data):
228
    def i2cwrite(self, index, slaveaddr, startaddr, data):
230
        """ Writes data to an i2c slave """
229
        """ Writes data to an i2c slave """
231
        size = len(data)
230
        size = len(data)
232
        if size > 256 or size < 1:
231
        if size > 256 or size < 1: