Hello
python module doesn't seem to handle enums . i've based my code on example code from official git repo. i can read objects without much problem but whenever i try scalers/unit/whateer that have enum values i get error from diffrent places in code trying to make unallowed operations on int objects (my meter returns int eg "<ContextId>1</ContextId>" instead of enum object
example of unallowed operations :
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSAssociationLogicalName.py", line 615, in load
self.xDLMSContextInfo.conformance = reader.readElementContentAsInt("Conformance")
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXXmlReader.py", line 107, in readElementContentAsInt
ret =int(str_)
ValueError: invalid literal for int() with base 10: 'Conformance.NONE'
it tries to convert "ApplicationContextName.LOGICAL_NAME" , should i add wrapper during reading that will convert enum value to int and only then save it as object or am i missing something ?
or during reading (i already fixed it by making changes to repo code so i don't have error message to show)
module tried to access writer.writeElementString("Unit", self.unit.name) in file GXDLMSExtendedRegister.py wich ofc returned error since message i've got was string without attribute name (fixed it by calling writer.writeElementString("Unit", Unit(self.unit).name)
thank you for reply
after update to gurux_dlms i've got this error during parsing objects
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 146, in <module>
client.parseObjects(reply.data, True)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 711, in parseObjects
c.updateOBISCodeInformation(objects)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSConverter.py", line 112, in updateOBISCodeInformation
self.__readStandardObisInfo(self.standard, self.codes)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSConverter.py", line 155, in __readStandardObisInfo
str_ = str_.replace("\n", "\r")
TypeError: a bytes-like object is required, not 'str'
gurux_dlms version 1.0.58
gurux_common version 1.0.13
gurux_net version 1.0.17
python version : 3.6.8
than you so much :D now parsing works again
sadly reading unit/scaler still doesnt work
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 160, in <module>
client.objects.save("dlmsobjs.xml")
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 146, in save
it.save(writer)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSExtendedRegister.py", line 197, in save
writer.writeElementString("Unit", self.unit.value)
AttributeError: 'int' object has no attribute 'value'
same problem as before. code assumes that unit is enum instead of int (it can be easily fixed by just passing self.unit but i don't know if change like that won't have further consequences in code)
EDIT:
after making mentioned change ( writer.writeElementString("Unit", self.unit)) i saved cosem objects into xml, and tried to read it . following error occured
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 117, in <module>
c = GXDLMSObjectCollection.load("dlmsobjs.xml")
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 127, in load
obj.load(reader)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSAssociationLogicalName.py", line 612, in load
self.applicationContextName.contextId = ApplicationContextName(reader.readElementContentAsInt("ContextId"))
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXXmlReader.py", line 103, in readElementContentAsInt
ret = int(str_)
ValueError: invalid literal for int() with base 10: 'ApplicationContextName.LOGICAL_NAME'
Process finished with exit code 1
used method "readElementContentAsInt" assumes that code is int written as a string, but it is name of enum
I believe we need to add a new distro for testing. What distro you are using? We tested those and it worked without problems and python version is the same.
thank you for help , still doesn't seem to work ValueError: invalid literal for int() with base 10: 'ApplicationContextName.LOGICAL_NAME' still exists even on new version. i'm using windows 10. as ide i'm using pycharm
Hi,
Thank you for this info.
It seems that pycharm python is working differently.
We'll install pycharm tomorrow morning for one of the test PCs and release new version after we can finish the tests.
Hi,
Hi,
Can you try to update to the latest version?
Run this:
pip install --upgrade gurux-dlms
Let me know if you have still problems. Let me also know your python version.
python --version
BR,
Mikko
after update to gurux_dlms i
thank you for reply
after update to gurux_dlms i've got this error during parsing objects
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 146, in <module>
client.parseObjects(reply.data, True)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 711, in parseObjects
c.updateOBISCodeInformation(objects)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSConverter.py", line 112, in updateOBISCodeInformation
self.__readStandardObisInfo(self.standard, self.codes)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\GXDLMSConverter.py", line 155, in __readStandardObisInfo
str_ = str_.replace("\n", "\r")
TypeError: a bytes-like object is required, not 'str'
gurux_dlms version 1.0.58
gurux_common version 1.0.13
gurux_net version 1.0.17
python version : 3.6.8
Hi,
Hi,
We was able to repeat this. I create an issue from this.
https://www.gurux.fi/node/15210
This is now fixed. Get the latest version.
BR,
Mikko
than you so much :D now
than you so much :D now parsing works again
sadly reading unit/scaler still doesnt work
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 160, in <module>
client.objects.save("dlmsobjs.xml")
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 146, in save
it.save(writer)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSExtendedRegister.py", line 197, in save
writer.writeElementString("Unit", self.unit.value)
AttributeError: 'int' object has no attribute 'value'
same problem as before. code assumes that unit is enum instead of int (it can be easily fixed by just passing self.unit but i don't know if change like that won't have further consequences in code)
EDIT:
after making mentioned change ( writer.writeElementString("Unit", self.unit)) i saved cosem objects into xml, and tried to read it . following error occured
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/dlmsdinconnect.py", line 117, in <module>
c = GXDLMSObjectCollection.load("dlmsobjs.xml")
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 127, in load
obj.load(reader)
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXDLMSAssociationLogicalName.py", line 612, in load
self.applicationContextName.contextId = ApplicationContextName(reader.readElementContentAsInt("ContextId"))
File "C:\Users\xxx\xxx\xxx\venv\lib\site-packages\gurux_dlms\objects\GXXmlReader.py", line 103, in readElementContentAsInt
ret = int(str_)
ValueError: invalid literal for int() with base 10: 'ApplicationContextName.LOGICAL_NAME'
Process finished with exit code 1
used method "readElementContentAsInt" assumes that code is int written as a string, but it is name of enum
Hi,
Hi,
This is fixed. Get the latest version (1.0.60).
I believe we need to add a new distro for testing. What distro you are using? We tested those and it worked without problems and python version is the same.
BR,
Mikko
thank you for help , still
thank you for help , still doesn't seem to work ValueError: invalid literal for int() with base 10: 'ApplicationContextName.LOGICAL_NAME' still exists even on new version. i'm using windows 10. as ide i'm using pycharm
Hi,
Hi,
Thank you for this info.
It seems that pycharm python is working differently.
We'll install pycharm tomorrow morning for one of the test PCs and release new version after we can finish the tests.
BR,
Mikko