Im using python 3.8 with:
code: Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python
gurux_dlms version: 1.0.74
gurux_net version: 1.0.17
gurux_serial version: 1.0.14
i am able to read a meter by serial port, but when i tried to save the xml data of the meter with the next command:
E:main.py -S COM2 -c 1 -s 145 -a Low -P 12345678 -C None -g "1.0.32.7.0.255:2" -o c:\device.xml -t Verbose
i got this error:
TX: 09:44:35 7E A0 1A 02 23 03 BA 35 6A E6 E6 00 C0 01 C1 00 03 01 00 20 07 00 FF 02 00 85 83 7E
RX: 09:44:35 7E A0 18 03 00 02 00 23 DA C3 D0 E6 E7 00 C4 01 C1 00 17 42 FC 8A 3D F5 3A 7E
Index: 2 Value: (126.2699966430664,)
Traceback (most recent call last):
File "main.py", line 105, in main
settings.client.objects.save(settings.outputFile)
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 152, in save
it.save(writer)
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXDLMSRegister.py", line 180, in save
writer.writeElementObject("Value", self.value, self.getDataType(2), self.getUIDataType(2))
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXXmlWriter.py", line 149, in writeElementObject
value = GXDLMSConverter.changeType(value, dt)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMSConverter.py", line 200, in changeType
if _GXCommon.getDLMSDataType(value) == type_:
File "C:\Python38\lib\site-packages\gurux_dlms\internal\_GXCommon.py", line 1660, in getDLMSDataType
elif isinstance(value, unicode):
NameError: name 'unicode' is not defined
DisconnectRequest
TX: 09:44:35 7E A0 08 02 23 03 53 32 B2 7E
RX: 09:44:35 7E A0 0A 03 00 02 00 23 73 7A 6A 7E
With the update(gurux-dlms==1.0.76) i cant read a variable that i can do before (gurux-dlms==1.0.75) the update:
d = gurux_dlms.objects.GXDLMSRegister(ln="1.0.32.7.0.255")
v = 2
va = reader.read(d, v)
TX: 11:25:21 7E A0 1A 02 23 03 32 75 62 E6 E6 00 C0 01 C1 00 03 01 00 20 07 00 FF 02 00 85 83 7E
RX: 11:25:22 7E A0 18 03 00 02 00 23 52 83 D8 E6 E7 00 C4 01 C1 00 17 42 FB C7 AE FC E6 7E
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1109, in getData
raise ex
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1106, in getData
ret = GXDLMS.getData(self.settings, reply, data, notify)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1880, in getData
cls.getPdu(settings, target)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1710, in getPdu
cls.getValueFromData(settings, data)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1825, in getValueFromData
value = _GXCommon.getData(settings, data, info)
File "C:\Python38\lib\site-packages\gurux_dlms\internal\_GXCommon.py", line 299, in getData
value = cls.getFloat(settings, data, info)
File "C:\Python38\lib\site-packages\gurux_dlms\internal\_GXCommon.py", line 662, in getFloat
return GXFloat32(value)
TypeError: float() argument must be a string or a number, not 'tuple'
I'm sorry about this. There were human error and serialization was not tested with the latest changes.
This is now fixed and version 1.0.79 is released.
It's recommended that you read association view only once and save it or if you know what you want to read, you don't read it at all. You need to know Logical Name (OBIS code).
Reading register value in this way is faster, but you need to know what you want to read.
You can read register value like this:
r = GXDLMSRegister("LOGICAL NAME")
self.read(r, 2)
Hi,
Hi,
There is now own data type for float32 and float64.
https://www.gurux.fi/node/15850
Run this and upgrade to the new version.
pip install --upgrade gurux-dlms
BR,
Mikko
Thanks Mikko,
Thanks Mikko,
With the update(gurux-dlms==1.0.76) i cant read a variable that i can do before (gurux-dlms==1.0.75) the update:
d = gurux_dlms.objects.GXDLMSRegister(ln="1.0.32.7.0.255")
v = 2
va = reader.read(d, v)
TX: 11:25:21 7E A0 1A 02 23 03 32 75 62 E6 E6 00 C0 01 C1 00 03 01 00 20 07 00 FF 02 00 85 83 7E
RX: 11:25:22 7E A0 18 03 00 02 00 23 52 83 D8 E6 E7 00 C4 01 C1 00 17 42 FB C7 AE FC E6 7E
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1109, in getData
raise ex
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1106, in getData
ret = GXDLMS.getData(self.settings, reply, data, notify)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1880, in getData
cls.getPdu(settings, target)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1710, in getPdu
cls.getValueFromData(settings, data)
File "C:\Python38\lib\site-packages\gurux_dlms\GXDLMS.py", line 1825, in getValueFromData
value = _GXCommon.getData(settings, data, info)
File "C:\Python38\lib\site-packages\gurux_dlms\internal\_GXCommon.py", line 299, in getData
value = cls.getFloat(settings, data, info)
File "C:\Python38\lib\site-packages\gurux_dlms\internal\_GXCommon.py", line 662, in getFloat
return GXFloat32(value)
TypeError: float() argument must be a string or a number, not 'tuple'
Regards,
Hi Mauricio ,
Hi Mauricio ,
Thank you for pointing this out. This is now fixed. Get the latest version.
https://www.gurux.fi/node/15870
BR,
Mikko
Hi Mikko,
Hi Mikko,
Now the file is saved, but i can not load it:
command: main.py -S COM2 -c 1 -s 145 -a Low -P 12345678 -C None -g "1.0.32.7.0.255:2" -o device.xml -t Verbose
python 3.8
gurux_dlms version: 1.0.78
gurux_net version: 1.0.17
gurux_serial version: 1.0.14
Authentication: Authentication.LOW
ClientAddress: 0x1
ServerAddress: 0x91
Standard: Standard.DLMS
TX: 10:18:46 7E A0 08 02 23 03 93 3E 74 7E
RX: 10:18:47 7E A0 23 03 00 02 00 23 73 C0 48 81 80 14 05 02 00 F8 06 02 04 B0 07 04 00 00 00 01 08 04 00 00 00 01 D8 CC 7E
TX: 10:18:47 7E A0 45 02 23 03 10 FB 7F E6 E6 00 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 31 32 33 34 35 36 37 38 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 10 10 FF FF E2 AA 7E
RX: 10:18:47 7E A0 3A 03 00 02 00 23 30 AF CC E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 10 10 04 B0 00 07 74 69 7E
Traceback (most recent call last):
File "main.py", line 91, in main
c = GXDLMSObjectCollection.load(settings.outputFile)
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXDLMSObjectCollection.py", line 131, in load
obj.load(reader)
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXDLMSExtendedRegister.py", line 204, in load
self.unit = Unit(reader.readElementContentAsInt("Unit", 0))
File "C:\Python38\lib\site-packages\gurux_dlms\objects\GXXmlReader.py", line 103, in readElementContentAsInt
ret = int(str_)
ValueError: invalid literal for int() with base 10: 'Unit.NONE'
DisconnectRequest
TX: 10:18:47 7E A0 08 02 23 03 53 32 B2 7E
RX: 10:18:47 7E A0 0A 03 00 02 00 23 73 7A 6A 7E
Hi Mauricio,
Hi Mauricio,
I'm sorry about this. There were human error and serialization was not tested with the latest changes.
This is now fixed and version 1.0.79 is released.
BR,
Mikko
Hi Mikko,
Hi Mikko,
everything is working, thanks for your support.
i have a question,
i can read an object from the meter using 2 ways:
1. read directly using GXDLMSRegister without a getAssociationView():
2. read using reader.read(settings.client.objects.findByLN(ObjectType.NONE, k), v).
What are the pros and cons of these two methods?
Thanks
Hi Mauricio,
Hi Mauricio,
It's recommended that you read association view only once and save it or if you know what you want to read, you don't read it at all. You need to know Logical Name (OBIS code).
Reading register value in this way is faster, but you need to know what you want to read.
You can read register value like this:
r = GXDLMSRegister("LOGICAL NAME")
self.read(r, 2)
BR,
Mikko