Skip to content

Commit

Permalink
adding bytes_val and leaflist_val with string_val parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoonovais committed Mar 7, 2024
1 parent 038564f commit 7cf6a61
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit 7cf6a61

Please sign in to comment.