def read_tlv(data):
def _parse(data, pos, size, result=None):<EOL><INDENT>if result is None:<EOL><INDENT>result = {}<EOL><DEDENT>if pos >= size:<EOL><INDENT>return result<EOL><DEDENT>tag = str(data[pos])<EOL>length = data[pos+<NUM_LIT:1>]<EOL>value = data[pos+<NUM_LIT:2>:pos+<NUM_LIT:2>+length]<EOL>if tag in result:<EOL><INDENT>result[tag] += value  <EOL><DEDENT>else:<EOL><INDENT>result[tag] = value<EOL><DEDENT>return _parse(data, pos+<NUM_LIT:2>+length, size, result)<EOL><DEDENT>return _parse(data, <NUM_LIT:0>, len(data))<EOL>
Parse TLV8 bytes into a dict.

    If value is larger than 255 bytes, it is split up in multiple chunks. So
    the same tag might occurr several times.