-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
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 |
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.
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 : |
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.
Why <5
We should have some inline comment explaining this.
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. |
Signed-off-by: ashwini-k-pandey <[email protected]>
Signed-off-by: ashwini-k-pandey <[email protected]>
No description provided.