def read(self, addr, length):
read_data = bytes()<EOL>read_length = length<EOL>for rmap in self.rmaps:<EOL><INDENT>regset = rmap.findRegisters(addr, read_length)<EOL>for reg in regset:<EOL><INDENT>if reg.addr > addr:<EOL><INDENT>read_data += bytes(reg.addr - addr)<EOL>read_length -= (reg.addr - addr)<EOL>addr += (reg.addr - addr)<EOL>reg_data = reg.read(<NUM_LIT:0>, min(read_length, reg.length))<EOL>raise genicam.GenericException(<EOL>"<STR_LIT>" % (addr, length), "<STR_LIT>", <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>reg_offs = addr - reg.addr<EOL>reg_data = reg.read(<EOL>reg_offs, min(read_length, reg.length - reg_offs))<EOL><DEDENT>read_data += reg_data<EOL>addr += len(reg_data)<EOL>read_length -= len(reg_data)<EOL><DEDENT><DEDENT>if length - len(read_data) > <NUM_LIT:0>:<EOL><INDENT>read_data += bytes(length - len(read_data))<EOL>raise genicam.GenericException("<STR_LIT>" % (addr, length), "<STR_LIT>",<EOL><NUM_LIT:0>)<EOL><DEDENT>return read_data<EOL>
is called on a read to a register
if the access to the register is smaller than the reg width,
this class handles the read of the relevant bytes
:param addr: base address of access
:param length: length of access