Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. GXDLMSTranslator Python

GXDLMSTranslator Python

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By Aashikms , 28 February, 2020
Forums
Gurux.DLMS

Hi,

I am trying to decrypt and analyse a wrapper push message sent from the Smart meter.
I used GXDLMS translator application in your website, after providing message and cipher key message was translated and able to read the message in XML format.
So to automate it i am planning to use your Python gurux_dlms libraries. Found GXDLMSTranslator object and in that when i passed the data to function messagetoXML i am getting following error.
below is the sample code.

code:
from gurux_dlms import *
data = "wrapper message"
t = GXDLMSTranslator(TranslatorOutputType.SIMPLE_XML)
t.security = enums.Security.AUTHENTICATION_ENCRYPTION
t.blockCipherKey =GXByteBuffer.hexToBytes("my 16 byte key")
xml = t.messageToXml(GXByteBuffer.hexToBytes(data))
print(xml)

error:
'NoneType' object has no attribute 'sourceSystemTitle'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\104714\AppData\Local\Programs\Python\Python38-32\lib\site-packages\gurux_dlms\GXDLMSTranslator.py", line 454, in messageToXml
raise ValueError("Invalid DLMS framing.")
ValueError: Invalid DLMS framing.

PS: the same message is getting decrypted in translator application message to xml window.

Aashikms

6 years 3 months ago

Hi,

Hi,
Please someone help me with this.
Below is the sample message i am decrypting.
000100010040007FDB085A454E4E30303032743000000167F751D9FDB255D234749EE29680A725090CC4D536516FF047D82A5066D7793AC798178384BC49DE85B725C8B0B10F6DFFAF0DFAD3FDA65B2B061F7108075AA47E58B8707D051E1A163CE3A00B77E7BDDD773742BF2E731AA47D850036816FAA410142B3B606B351FA35DF57E752464B

And below is the screenshot of the DLMS translator application:

Image
Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

We have fixed this to the Python and try to release a new version today after the tests are over.

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

I have updated python package and ran above example and i am getting below error.
Error:
'GXDLMSSettings' object has no attribute 'setClientAddress'
Traceback (most recent call last):
File "server.py", line 33, in <module>
xml = t.messageToXml(GXByteBuffer.hexToBytes(data))
File "C:\Users\104714\AppData\Local\Programs\Python\Python38-32\lib\site-packages\gurux_dlms\GXDLMSTranslator.py", line 454, in messageToXml
raise ValueError("Invalid DLMS framing.")
ValueError: Invalid DLMS framing.

Am i missing something or this is a bug.

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi Aashik,

Hi Aashik,

Thank you for this info. This is now fixed and the new version is released (1.0.52).

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Thanks for the fix, Now i am able to get the XML data in ciphered format. Even after providing Block ciphered key i am getting only XML output as below.

Output:
<WRAPPER len="0" >
<TargetAddress Value="0" />
<SourceAddress Value="0" />
<PDU>
<GeneralGloCiphering>
<SystemTitle Value="5A454E4E30303032" />
<CipheredService Value="3000000167F751D9FDB255D234749EE29680A725090CC4D536516FF047D82A5066D7793AC798178384BC49DE85B725C8B0B10F6DFFAF0DFAD3FDA65B2B061F7108075AA47E58B8707D051E1A163CE3A00B77E7BDDD773742BF2E731AA47D850036816FAA410142B3B606B351FA35DF57E752464B" />
</GeneralGloCiphering>
</PDU>
</WRAPPER>

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

Check your block cipher key. I believe that it's not correct.

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Block Cypher key is correct as the same worked properly when i checked with DLMS translator application.
And also in XML output of python script Wrapper length, source and destination address is showing as 0.

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,
We improved this. You need to set security and comments before data is shown.
http://www.gurux.fi/node/15061

Get the latest version and add comments.

t = GXDLMSTranslator()
t.comments = True

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Thanks for quick reply, But still XML message is not complete below is the output i am getting after adding comment and security.

<WRAPPER len="87" >
<TargetAddress Value="1" />
<SourceAddress Value="40" />
<PDU>
-->ial number: 3158066ector extension, Load Management extension
<GeneralGloCiphering>
<SystemTitle Value="5A454E4E30303032" />
<CipheredService Value="3000000167F751D9FDB255D234749EE29680A725090CC4D536516FF047D82A5066D7793AC798178384BC49DE85B725C8B0B10F6DFFAF0DFAD3FDA65B2B061F7108075AA47E58B8707D051E1A163CE3A00B77E7BDDD773742BF2E731AA47D850036816FAA410142B3B606B351FA35DF57E752464B" />
</GeneralGloCiphering>
</PDU>
</WRAPPER>

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

Have you updated to version 1.0.53 and your code looks like this?

from gurux_dlms import *
data = "wrapper message"
t = GXDLMSTranslator(TranslatorOutputType.SIMPLE_XML)
t.comments = True
t.blockCipherKey =GXByteBuffer.hexToBytes("my 16 byte key")
xml = t.messageToXml(GXByteBuffer.hexToBytes(data))
print(xml)

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Yes i have updated the package to 1.0.53 and Code is same as above.

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

Have you also set block cipher key? All lines are something like this.

GXDLMSTranslator t = new GXDLMSTranslator(TranslatorOutputType.SIMPLE_XML);
t.setComments(true);
t.setSystemTitle("Client system title");
t.setBlockCipherKey("YOUR BLOCK CIPHER KEY");
t.setServerSystemTitle("Server system title");
t.messageToXml(data);

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Yes i have set block ciphered key and comments. also i have added system title also to check.
But getting the same output.

If you check the output we are getting the comment but the decrypted message in the comment is not complete.

Decrypted output in Python SDK:
<PDU>
-->ial number: 3158066ector extension, Load Management extension
<GeneralGloCiphering>

Decrypted output in Translator application:
<!--
IDIS system title:
Manufacturer Code: ZEN
Function type: Disconnector extension, Load Management extension
Serial number: 3158066
-->
<!--Decrypt data: 0F D0 00 00 6A 0C 07 E4 02 0B 02 0D 00 02 FF 01 4A 00 02 0D 0A 0A 5A 45 4E 5A 45 4E 30 30 30 32 09 06 00 00 19 09 00 FF 09 0C 07 E4 02 0B 02 0D 00 02 FF 01 4A 00 17 43 6E FD 71 17 00 00 00 00 17 00 00 00 00 17 00 00 00 00 17 00 00 00 00 12 00 09 06 00 00 00 00 17 00 00 00 00 03 01 06 00 00 43 80
<DataNotification>
<LongInvokeIdAndPriority Value="D000006A" />
<!--12-02-2020 12:00:02 AM-->
<DateTime Value="07E4020B020D0002FF014A00" />
<NotificationBody>
<DataValue>
<Structure Qty="0D" >
<String Value="ZENZEN0002" />
<!--0.0.25.9.0.255-->
<OctetString Value="0000190900FF" />
<!--12-02-2020 12:00:02 AM-->
<OctetString Value="07E4020B020D0002FF014A00" />
<!--238.99-->
<Float32 Value="436EFD71" />
<!--0-->
<Float32 Value="00000000" />
<!--0-->
<Float32 Value="00000000" />
<!--0-->
<Float32 Value="00000000" />
<!--0-->
<Float32 Value="00000000" />
<UInt16 Value="0009" />
<UInt32 Value="00000000" />
<!--0-->
<Float32 Value="00000000" />
<Boolean Value="true" />
<UInt32 Value="00004380" />
</Structure>
</DataValue>
</NotificationBody>
</DataNotification>
-->
<GeneralGloCiphering>

So the above comments which has to be shown is not properly showing in Python SDK.

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

That is data what meter returns. If you want something else, you need to configure the meter to send it.

BR,
Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

But the same message is properly decoding in the Translator application but not in Python sdk.

Profile picture for user Kurumi

Kurumi

6 years 3 months ago

Hi,

Hi,

Update to the latest version:
pip install --upgrade gurux-dlms

Try with this. Then update your authentication and block cipher keys and try with your data.

from gurux_dlms import GXDLMSTranslator
from gurux_dlms import GXByteBuffer
data = "00 01 00 01 00 10 00 58 DB 08 41 42 43 44 45 46 47 48 4D 30 00 00 00 00 11 98 4B 30 35 F0 35 51 06 72 DA 54 93 70 8E 70 9B 3D BD 31 02 14 CE 10 A9 89 81 92 53 80 42 A9 19 D7 52 62 7B E6 70 B3 13 30 E1 53 B6 9D 0B 6D 14 8D 86 F9 D4 6F 6B C3 09 24 A8 4C 50 03 82 FF 05 77 A5 9B F1 1F CD 78"
t = GXDLMSTranslator()
t.comments = True
t.systemTitle = "ABCDEFGH".encode()
t.blockCipherKey = bytearray((0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F))
t.authenticationKey = bytearray((0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF))
t.serverSystemTitle = GXByteBuffer.hexToBytes("4142434445464748")
print(t.messageToXml(data))

BR,

Mikko

Aashikms

6 years 3 months ago

Hi Mikko,

Hi Mikko,

Thanks now i am getting the output.

rudreshmr@gmail.com

4 years 10 months ago

Hi Mikko Kurunsaari,

Hi Mikko Kurunsaari,
Why this <DataNotification> is commented in GXDLMSTranslator XMLResponse and its added in comment section? is there any other API which gives decrypted hex.

Thanks
Rudresh

Profile picture for user Kurumi

Kurumi

4 years 10 months ago

In reply to Hi Mikko Kurunsaari, by rudreshmr@gmail.com

Hi Rudresh,

Hi Rudresh,

Please, create a new topic if you have a new question. Add also what programming language you are using.

BR,
Mikko

ravichandra99

3 years 12 months ago

In reply to Hi, by Kurumi

Hi Mikko

Hi Mikko

I was able to get encrypted data and Im using the above code to decrypt data

and using xml = t.messageToXml(GXByteBuffer.hexToBytes(data)) before last line.. im still getting encrypted data

what is serverSystemTitle? is it same as systemTitle?

ravichandra99

3 years 12 months ago

In reply to Hi Mikko by ravichandra99

this is data output i got in

this is data output i got in xml file .. https://pastebin.com/W2XtWtR4

Profile picture for user Kurumi

Kurumi

3 years 12 months ago

In reply to this is data output i got in by ravichandra99

Hi Ravi ,

Hi Ravi ,

Please, create a new topic if you have a new question. I'll answer for your question there.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin