1

New chunking logic

This commit is contained in:
Evan Pratten 2024-11-21 15:24:31 -05:00
parent 57b4f2e52c
commit a4b2ea29ee

View File

@ -36,6 +36,7 @@ def main() -> int:
rbn_socket.sendall(b'va3ujf\r\n') rbn_socket.sendall(b'va3ujf\r\n')
# Handle incoming RBN spots # Handle incoming RBN spots
buffer = b''
while True: while True:
# Read incoming packet (may contain multiple spots) # Read incoming packet (may contain multiple spots)
@ -43,8 +44,14 @@ def main() -> int:
if not data: if not data:
break break
# Append to buffer
buffer += data
# Split the packet into spots # Split the packet into spots
for spot in data.splitlines(): if b'\r\n' in buffer:
chunks = buffer.splitlines()
buffer = chunks.pop() # Store the un-finished chunk for later
for spot in chunks:
# Some lines aren't spots # Some lines aren't spots
if not spot.startswith(b'DX'): if not spot.startswith(b'DX'):
continue continue