Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hexadecimal state handling to excel_to_xtce #1159

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

sdhoyt
Copy link
Contributor

@sdhoyt sdhoyt commented Nov 13, 2024

Change Summary

Overview

Some telemetry definition housekeeping state values are listed in hexadecimal form. space-packet-parser requires states to be in decimal form. This PR adds a function to ensure that the state value is an integer or a hexadecimal string is converted to an integer.

Closes #1158

@sdhoyt sdhoyt added enhancement New feature or request packet parsing Related to packet parsing or XTCE labels Nov 13, 2024
@sdhoyt sdhoyt requested review from subagonsouth and a team November 13, 2024 23:36
@sdhoyt sdhoyt self-assigned this Nov 13, 2024
@sdhoyt sdhoyt requested review from vmartinez-cu, laspsandoval and maxinelasp and removed request for a team November 13, 2024 23:36
Comment on lines 419 to 423
if isinstance(value, str) and value.startswith("0x"):
state["value"] = int(value, 16)
return state
# return if already an int
elif isinstance(value, int):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If integers are more common than hex values, you could switch the if/elif logic to check if value is an integer first. There might be a slight performance gain there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll update that

Copy link
Contributor

@vmartinez-cu vmartinez-cu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! One minor comment, but not something that would block a merge

@sdhoyt sdhoyt requested a review from tech3371 November 18, 2024 17:31
Copy link
Contributor

@tech3371 tech3371 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM!

@@ -197,7 +197,7 @@ def xtce_excel_file(tmp_path):
states = {
"packetName": ["TEST_PACKET"] * 2,
"mnemonic": ["VAR_STATE"] * 2,
"value": [0, 1],
"value": [0, "0x1"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add this hex test as another one without deleting that one? I think we need to test that also

Copy link
Contributor

@subagonsouth subagonsouth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sdhoyt sdhoyt merged commit f7847ab into IMAP-Science-Operations-Center:dev Nov 19, 2024
17 checks passed
@sdhoyt sdhoyt deleted the add-hex branch November 19, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request packet parsing Related to packet parsing or XTCE
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

excel to xtce should handle hexadecimal state values
4 participants