def read_range (self, address, length):
# Can only read up to 4095 bytes at a time.
MAX_READ = 4095
read = bytes()
this_length = 0
remaining = length
while remaining > 0:
if remaining > MAX_READ:
this_length = MAX_READ
remaining -= MAX_READ
else:
this_length = remaining
remaining = 0
message = struct.pack('<IH', address, this_length)
success, flash = self._issue_command(self.COMMAND_READ_RANGE, message, True, this_length, self.RESPONSE_READ_RANGE)
if not success:
raise TockLoaderException('Error: Could not read flash')
else:
read += flash
address += this_length
return read
评论列表
文章目录