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

Handling of singed int of protobuf payload #46

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

ashwini-k-pandey
Copy link
Contributor

No description provided.

Signed-off-by: Ashwini Kumar Pandey <[email protected]>
@@ -297,13 +297,17 @@ def on_message(self, client, userdata, msg):
device_readings = {}
for metric in sparkplug_payload.metrics:
value = "Unknown"
data_type = metric.datatype
Copy link
Member

Choose a reason for hiding this comment

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

Should we check has field data_type?

If missing is that an error and should be logged?

if metric.HasField("boolean_value"):
""" bool value cast to int as internal. See FOGL-8067 """
value = metric.boolean_value
elif metric.HasField("float_value"):
value = metric.float_value
elif metric.HasField("int_value"):
value = metric.int_value
if data_type < 5 :
Copy link
Member

Choose a reason for hiding this comment

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

Why <5
We should have some inline comment explaining this.

@firozalikhan
Copy link

For smaller than the minimum value (-2147483648) of a signed 32-bit integer say -2147483649, it ingests the max value of signed 32-int i.e. 2147483647.
For larger than the max value (2147483647) of a singed 32-bit integer say 2147483648, it ingests the min value of singed 32-int, i.e. -2147483648.

Signed-off-by: ashwini-k-pandey <[email protected]>
Signed-off-by: ashwini-k-pandey <[email protected]>
@ashwini-k-pandey ashwini-k-pandey changed the title Draft PR Handling of singed int of protobuf payload Handling of singed int of protobuf payload Jan 3, 2025
@ashwini-k-pandey ashwini-k-pandey merged commit d45a2ad into develop Jan 7, 2025
2 checks passed
@ashwini-k-pandey ashwini-k-pandey deleted the DRAFT-DATATYPE-HANDLING branch January 7, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants