def from_bytes(self, data):
packet_tag = data[0]
+ offset = 1
always_one = packet_tag & 1 << 7
if not always_one:
raise ValueError('most significant packet tag bit not set')
raise NotImplementedError(
'old-format packet of indeterminate length')
length_format = '>{}'.format(length_type)
- length_data = data[1: 1 + length_bytes]
+ length_data = data[offset: offset + length_bytes]
+ offset += length_bytes
self['length'] = _struct.unpack(length_format, length_data)[0]
+ packet = data[offset:offset + self['length']]
+ offset += self['length']
+ return offset
def to_bytes(self):
pass