Skip to content

Commit

Permalink
Merge pull request #151 from akarneliuk/bytes_val_leaflist_val
Browse files Browse the repository at this point in the history
adding bytes_val and leaflist_val with string_val parsing
  • Loading branch information
akarneliuk committed Mar 9, 2024
2 parents 038564f + 7cf6a61 commit 48f9caa
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 48f9caa

Please sign in to comment.