Skip to content

Commit 48f9caa

Browse files
authored
Merge pull request #151 from akarneliuk/bytes_val_leaflist_val
adding bytes_val and leaflist_val with string_val parsing
2 parents 038564f + 7cf6a61 commit 48f9caa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pygnmi/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,16 @@ def telemetryParser(in_message=None, debug: bool = False):
12661266
update_container.update({"val": update_msg.val.proto_bytes})
12671267

12681268
elif update_msg.val.HasField("bytes_val"):
1269-
update_container.update({"val": update_msg.val.bytes_val})
1269+
val_binary = ''.join(format(byte, '08b') for byte in update_msg.val.bytes_val)
1270+
val_decimal = struct.unpack("f", struct.pack("I", int(val_binary, 2)))[0]
1271+
update_container.update({'val': val_decimal})
1272+
1273+
elif update_msg.val.HasField('leaflist_val'):
1274+
val_leaflist = update_msg.val
1275+
element_str = ""
1276+
for element in val_leaflist.leaflist_val.element:
1277+
element_str += element
1278+
update_container.update({'val': element_str})
12701279

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

0 commit comments

Comments
 (0)