-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
if isinstance(value, str) and value.startswith("0x"): | ||
state["value"] = int(value, 16) | ||
return state | ||
# return if already an int | ||
elif isinstance(value, int): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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"], |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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