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

ieeefloat32 parsing #110

Open
brunoonovais opened this issue Jan 18, 2023 · 9 comments
Open

ieeefloat32 parsing #110

brunoonovais opened this issue Jan 18, 2023 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@brunoonovais
Copy link
Collaborator

If a bytes_val is received, TelemetryParser is not displaying/parsing it.
I've added the following code and it works fine. Is it ok to integrate?

diff --git a/pygnmi/client.py b/pygnmi/client.py
index de2abf3..a2cff8d 100644
--- a/pygnmi/client.py
+++ b/pygnmi/client.py
@@ -13,6 +13,7 @@ import os
 from typing import Any
 import cryptography
 import grpc
+import struct
 from pygnmi.spec.v080.gnmi_pb2_grpc import gNMIStub
 from pygnmi.spec.v080.gnmi_pb2 import (CapabilityRequest, Encoding, GetRequest,\
     SetRequest, Subscription, Update, TypedValue, SubscribeRequest, Poll, SubscriptionList,\
@@ -456,6 +457,12 @@ class gNMIclient(object):
                                     elif update_msg.val.HasField('proto_bytes'):
                                         update_container.update({'val': update_msg.val.proto_bytes})

+                                   elif update_msg.val.HasField('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(binary, 2)))[0]
+                                        update_container.update({'val': val_decimal})
+
+
                                 notification_container['update'].append(update_container)

                         response['notification'].append(notification_container)
@akarneliuk
Copy link
Owner

Hello @brunoonovais ,

looks good for me. Could you please submit PR?

Thanks,
Anton

@akarneliuk akarneliuk added the bug Something isn't working label Feb 11, 2023
@brunoonovais
Copy link
Collaborator Author

looks like i don't have permissions to push to the repository yet:

bnovais@bnovais pygnmi % git push --set-upstream origin issue_110
ERROR: Permission to akarneliuk/pygnmi.git denied to brunoonovais.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
bnovais@bnovais pygnmi %

@akarneliuk
Copy link
Owner

Hello @brunoonovais ,
sorry, it appears it took a while for me to find that this message, sorry about it. I've added you as a collaborator.
Best,
Anton

@brunoonovais
Copy link
Collaborator Author

oops sorry @akarneliuk , i could not get to it. do you mind sending the invitation again, please?

@akarneliuk
Copy link
Owner

Hey @brunoonovais ,
is that still to be done?

@brunoonovais
Copy link
Collaborator Author

brunoonovais commented Oct 29, 2023 via email

@akarneliuk
Copy link
Owner

@brunoonovais ,
in that case, please check your mail now, you shall have invitation:

@brunoonovais
Copy link
Collaborator Author

brunoonovais commented Oct 30, 2023 via email

@akarneliuk
Copy link
Owner

Hey @brunoonovais , was that ever implemented, mate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants