-
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.
Update sort_packets to actually sort packets where a PSC rollover occ…
…urs.
- Loading branch information
1 parent
9578f95
commit b3c540d
Showing
5 changed files
with
147 additions
and
21 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
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,36 @@ | ||
""" | ||
This is the setup file for managing the emit_sds_l0 package | ||
Author: Winston Olson-Duvall, [email protected] | ||
""" | ||
|
||
import setuptools | ||
|
||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
name="emit_sds_l0", | ||
version="0.0.0", | ||
author="Winston Olson-Duvall", | ||
author_email="[email protected]", | ||
description=""" | ||
L0 scripts and PGEs for EMIT data processing, including pcap->hosc, hosc->ccsds, and helper utilities. | ||
""", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.jpl.nasa.gov/emit-sds/emit-sds-l0", | ||
packages=setuptools.find_packages(), | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires=">=3", | ||
install_requires=[ | ||
"sortedcontainers>=2.4.0", | ||
"pytest>=6.2.1", | ||
"pytest-cov>=2.10.1", | ||
"pycodestyle>=2.6.0" | ||
] | ||
) |
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
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,58 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
|
||
import emit.data_products as dp | ||
|
||
HOSC_HEADER_SIZE = 28 | ||
MAX_PSC = 790 | ||
|
||
|
||
def main(): | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Artificially insert a PSC rollover in a HOSC stream for testing purposes" | ||
) | ||
parser.add_argument('input_file') | ||
args = parser.parse_args() | ||
|
||
in_file = open(args.input_file, 'rb') | ||
outfile = open(args.input_file.replace(".bin", "_rollover.bin"), "wb") | ||
|
||
cnt = 0 | ||
while True: | ||
try: | ||
# Read past HOSC header | ||
hosc_hdr = in_file.read(HOSC_HEADER_SIZE) | ||
|
||
# Read in packet and copy header to update PSCs | ||
pkt = dp.CCSDSPacket(in_file) | ||
hdr = bytearray(pkt.hdr_data) | ||
|
||
print(f"PSC before: {pkt.pkt_seq_cnt}") | ||
pkt.pkt_seq_cnt = pkt.pkt_seq_cnt % MAX_PSC | ||
print(f"PSC after: {pkt.pkt_seq_cnt}") | ||
|
||
# Update PSC bytes in header | ||
psc_bytes = pkt.pkt_seq_cnt.to_bytes(2, byteorder="big", signed=False) | ||
print("psc: " + str([bin(psc_bytes[i])[2:].zfill(8) for i in range(2)])) | ||
# Reset 14 bits of PSC to 0 | ||
hdr[2] = hdr[2] & 0xC0 | ||
hdr[3] = 0x00 | ||
# Add new PSC (preserving the leftmost 2 bits) | ||
hdr[2] = hdr[2] | psc_bytes[0] | ||
hdr[3] = hdr[3] | psc_bytes[1] | ||
|
||
# Write out file | ||
outfile.write(hosc_hdr) | ||
outfile.write(hdr) | ||
outfile.write(pkt.body) | ||
cnt += 1 | ||
except EOFError: | ||
break | ||
|
||
print(f"Count: {cnt}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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