Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7565829

Browse files
committedMar 7, 2025··
MNT: pop packets once completed to clean up dictionary storage
1 parent b78a89e commit 7565829

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎space_packet_parser/packets.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def ccsds_generator(
432432
elif ccsds_packet.sequence_flags == SequenceFlags.FIRST:
433433
_segmented_packets[ccsds_packet.apid] = [ccsds_packet]
434434
continue
435-
elif not _segmented_packets.get(ccsds_packet.apid, []):
435+
elif not _segmented_packets.get(ccsds_packet.apid, False):
436436
warnings.warn("Continuation packet found without declaring the start, "
437437
f"skipping packet with apid {ccsds_packet.apid}.")
438438
continue
@@ -443,21 +443,21 @@ def ccsds_generator(
443443
_segmented_packets[ccsds_packet.apid].append(ccsds_packet)
444444
# We have received the final packet, close it up and combine all of
445445
# the segmented packets into a single "packet" for XTCE parsing
446-
sequence_counts = [p.sequence_count for p in _segmented_packets[ccsds_packet.apid]]
446+
packets = _segmented_packets.pop(ccsds_packet.apid)
447+
sequence_counts = [p.sequence_count for p in packets]
447448
if not all((sequence_counts[i + 1] - sequence_counts[i]) % 16384 == 1
448449
for i in range(len(sequence_counts) - 1)):
449450
warnings.warn(f"Continuation packets for apid {ccsds_packet.apid} "
450451
f"are not in sequence {sequence_counts}, skipping these packets.")
451452
continue
452453
# Add all content (including header) from the first packet
453-
raw_data = _segmented_packets[ccsds_packet.apid][0]
454+
raw_data = packets[0]
454455
# Add the continuation packets to the first packet, skipping the headers
455-
for p in _segmented_packets[ccsds_packet.apid][1:]:
456+
for p in packets[1:]:
456457
raw_data += p[header_length_bytes + secondary_header_bytes:]
457458
yield CCSDSPacketBytes(raw_data)
458459

459460

460-
461461
if show_progress:
462462
_print_progress(current_bytes=n_bytes_parsed, total_bytes=total_length_bytes,
463463
start_time_ns=start_time, current_packets=n_packets_parsed,

0 commit comments

Comments
 (0)
Please sign in to comment.