-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility for checking packet sequence
- Loading branch information
1 parent
85748eb
commit 6e2d51d
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |