Skip to content

Commit

Permalink
Add utility for checking packet sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
winstonolson committed Aug 29, 2022
1 parent 85748eb commit 6e2d51d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions util/packet_sequence_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python

import argparse

import emit.data_products as dp

HOSC_HEADER_LEN = 28

parser = argparse.ArgumentParser()
parser.add_argument("infile")
args = parser.parse_args()

in_file = open(args.infile, "rb")
prev_psc = 0
count = 0

with open(in_file, "rb") as f:
while True:
try:
# Read hosc header
hosc_header = f.read(HOSC_HEADER_LEN)
# Read a packet
pkt = dp.CCSDSPacket(stream=f)
if (prev_psc + 1) % 16384 != pkt.pkt_seq_cnt and count > 0:
print(f"Out of order - prev_psc is {prev_psc}, current psc is {pkt.pkt_seq_cnt}")
print(pkt)
count += 1
except EOFError:
break

print(f"Total packets: {count}")

0 comments on commit 6e2d51d

Please sign in to comment.