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

adding bytes_val and leaflist_val with string_val parsing #151

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,16 @@ def telemetryParser(in_message=None, debug: bool = False):
update_container.update({"val": update_msg.val.proto_bytes})

elif update_msg.val.HasField("bytes_val"):
update_container.update({"val": update_msg.val.bytes_val})
val_binary = ''.join(format(byte, '08b') for byte in update_msg.val.bytes_val)
val_decimal = struct.unpack("f", struct.pack("I", int(val_binary, 2)))[0]
update_container.update({'val': val_decimal})

elif update_msg.val.HasField('leaflist_val'):
val_leaflist = update_msg.val
element_str = ""
for element in val_leaflist.leaflist_val.element:
element_str += element
update_container.update({'val': element_str})

response["update"]["update"].append(update_container)

Expand Down
Loading