From 6e2d51d46d303145d4b1896f0ac5bc182824e9af Mon Sep 17 00:00:00 2001 From: Winston Olson-Duvall Date: Mon, 29 Aug 2022 08:53:12 -0700 Subject: [PATCH] Add utility for checking packet sequence --- util/packet_sequence_check.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 util/packet_sequence_check.py diff --git a/util/packet_sequence_check.py b/util/packet_sequence_check.py new file mode 100644 index 0000000..c155d51 --- /dev/null +++ b/util/packet_sequence_check.py @@ -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}")