This is my first time trying to get data on DLMS in python.
GXDLMSDirector connects everything, everything is visible.
I tried the example from Gurux.DLMS.Client.Example.python/main.py and it also reads everything, but it reads all the parameters.
Is there an example of code where I could read the list of OBIS codes that I need, because everything I tried didn't work for me?
Hi, When you read the…
Hi,
When you read the association, it will describe features the meter can offer.
You need to check what you want to read from the meter and modify the client example for your needs.
BR,
Mikko
I'm using the example script…
I'm using the example script, which reads all codes and values from the counter using the reader.readAll() function. It works. One caveat is that when using the '-o output.xml' flag, the configuration isn't saved to the file, and everything is read anew each time, but that's a different issue. GXDLMSDirector also reads everything.
But I want to get the values of a specific OBIS code, say "0.0.1.0.0.255." To do this, I use:
reader.readAll()
This code (from examples here on the forum):
obj = GXDLMSClock("0.0.1.0.0.255")
reader.read(obj, 2)
But I get an error:
Data send failed. Try to resend 1/3
Data send failed. Try to resend 2/3
RX: 13:22:33
Traceback (most recent call last):
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\main2.py", line 120, in main
reader.read(obj, 2)
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 409, in read
self.readDataBlock(data, reply)
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 235, in readDataBlock
self.readDLMSPacket(data, reply)
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 164, in readDLMSPacket
self.readDLMSPacket2(data, reply)
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 222, in readDLMSPacket2
raise e
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 213, in readDLMSPacket2
raise TimeoutException(
gurux_common.TimeoutException.TimeoutException: Failed to receive reply from the device in given time.
Ended. Press any key to continue.
If I run it with the command…
If I run it with the command:
py main.py -S COM2:9600:8None1 -i HdlcWithModeE -c 3 -s 22922 -a Low -P ABCDEFGH -g "0.0.1.0.0.255:2"
I get the error:
C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\main.py:52: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
gurux_dlms version: 1.0.191
gurux_net version: 1.0.23
gurux_serial version: 1.0.21
['main.py', '-S', 'COM2:9600:8None1', '-i', 'HdlcWithModeE', '-c', '3', '-s', '22922', '-a', 'Low', '-P', 'ABCDEFGH', '-g', '0.0.1.0.0.255:2']
Authentication: 1
ClientAddress: 0x3
ServerAddress: 0x598a
Standard: 0
Traceback (most recent call last):
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\main.py", line 111, in main
reader.initializeConnection()
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 382, in initializeConnection
self.initializeOpticalHead()
File "C:\projects\server\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 254, in initializeOpticalHead
raise Exception("Failed to received reply from the media.")
Exception: Failed to received reply from the media.
Ended. Press any key to continue.
Sorry, but the script ended…
Sorry, but the script ended up with the following parameters:
py main.py -S COM2:9600:8None1 -c 3 -s 22922 -a Low -P ABCDEFGH -g "0.0.1.0.0.255:2"
It worked. I spent a long time reading it each time, but I added the -o flag with the .xml file and it worked perfectly.
Hi, The reason for this is…
Hi,
The reason for this is that your meter doesn't support Mode E when you are using the optical probe. The meter is using only HDLC.
BR,
Mikko