From 7cf6a61522077968608a741a2deef9084a2dfe98 Mon Sep 17 00:00:00 2001 From: Bruno Novais Date: Thu, 7 Mar 2024 10:24:54 -0500 Subject: [PATCH] adding bytes_val and leaflist_val with string_val parsing --- pygnmi/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pygnmi/client.py b/pygnmi/client.py index b6fcec7..29d6003 100644 --- a/pygnmi/client.py +++ b/pygnmi/client.py @@ -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)