Skip to content
Snippets Groups Projects
Commit f2d826b5 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-676: Fully support different packet header lengths, avoid parsing a packet multiple times.

parent 88edf029
No related branches found
No related tags found
1 merge request!266L2SS-676: Support parsing beamlet packets
......@@ -499,16 +499,22 @@ def read_packet(read_func) -> SDPPacket:
If read_func() returns None, this function will as well.
"""
# read just the header
header = read_func(SDPPacket.header_size)
if not header:
# read just the marker
marker = read_func(1)
if not marker:
return None
# marker is the first byte of the header
marker = header[0]
# read the packet header based on type
packetClass = PACKET_CLASS_FOR_MARKER[marker]
# read the rest of the header
header = read_func(packetClass.header_size - len(marker))
if not header:
return None
header = marker + header
# parse the packet header size
packet = packetClass(header)
# read the payload
......@@ -534,7 +540,7 @@ def main(args=None, **kwargs):
offset = 0
while True:
# read just the header
# read the packet from input
packet = read_packet(sys.stdin.buffer.read)
# print header
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment