@@ -432,7 +432,7 @@ def ccsds_generator(
432
432
elif ccsds_packet .sequence_flags == SequenceFlags .FIRST :
433
433
_segmented_packets [ccsds_packet .apid ] = [ccsds_packet ]
434
434
continue
435
- elif not _segmented_packets .get (ccsds_packet .apid , [] ):
435
+ elif not _segmented_packets .get (ccsds_packet .apid , False ):
436
436
warnings .warn ("Continuation packet found without declaring the start, "
437
437
f"skipping packet with apid { ccsds_packet .apid } ." )
438
438
continue
@@ -443,21 +443,21 @@ def ccsds_generator(
443
443
_segmented_packets [ccsds_packet .apid ].append (ccsds_packet )
444
444
# We have received the final packet, close it up and combine all of
445
445
# 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 ]
447
448
if not all ((sequence_counts [i + 1 ] - sequence_counts [i ]) % 16384 == 1
448
449
for i in range (len (sequence_counts ) - 1 )):
449
450
warnings .warn (f"Continuation packets for apid { ccsds_packet .apid } "
450
451
f"are not in sequence { sequence_counts } , skipping these packets." )
451
452
continue
452
453
# Add all content (including header) from the first packet
453
- raw_data = _segmented_packets [ ccsds_packet . apid ] [0 ]
454
+ raw_data = packets [0 ]
454
455
# 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 :]:
456
457
raw_data += p [header_length_bytes + secondary_header_bytes :]
457
458
yield CCSDSPacketBytes (raw_data )
458
459
459
460
460
-
461
461
if show_progress :
462
462
_print_progress (current_bytes = n_bytes_parsed , total_bytes = total_length_bytes ,
463
463
start_time_ns = start_time , current_packets = n_packets_parsed ,
0 commit comments