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. Gurux DLMS Translator : Python : Compile Error

Gurux DLMS Translator : Python : Compile Error

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 Norbert , 9 April, 2022
Forums
Gurux.DLMS

Hello
running DLMS Translator at RPi4 and get this error:
Traceback (most recent call last):

while translator.findNextFrame(msg, pdu):
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMSTranslator.py", line 171, in findNextFrame
elif msg.interfaceType in (None, InterfaceType.WRAPPER) and data.getUInt16(data.position) == 0x1:
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXByteBuffer.py", line 321, in getUInt16
raise ValueError("getUInt16")
ValueError: getUInt16

The message comes from a Sagemcom T210-D, Austria, EVN

Message
6801016853ff000167db085341475905e91a5d81f820000835cd7aaa2ca1bbb5795ba7b572d596b2789120da502579556a040f3056197cae9a9146a330ce74f1ee19bbdb5e7b66446b59062efada35c5a7ba69f087680939dc06d7cd9eb66af4e21bf1f5debfd46976af204dc2c7f5416590135248d49fb6ec241b5e79d564e1bb5d50351f494d48a09653deff478586f6679986d72d15779c511df997719bd9e232f1af6001eec37b0c4138de1647c92a1f232c8ed74bcff5dd4a303151783132fd949ad83d050b0c83e3d083e3493b4c10956e3500b3abdf2623099c140fb65599380177b99c4954f29c809191af32810a77eb27efa14bc510c6c79370110065eed331784a16680d0d6853ff11016720ed47bef4b74c5a2e16

Key
B829C67DC9DF3D9A81068540AD4C13E1

Messages from a Kaifa, Austria, EVN, will be translated without errors (starts with 68FAFA6853FF000167DB084B464D65509AE04281F82000004...)

Please assist, thanks
Norbert

Profile picture for user Kurumi

Kurumi

4 years 2 months ago

Hi Norbert,

Hi Norbert,

Lenght of L-field is invalid. It's one and that is not true. So this is a meter issue.

68
01 //WRONG. L-Field, length field, number of user data octets

BR,
Mikko

Profile picture for user Kurumi

Kurumi

4 years 2 months ago

Hi,

Hi,

The problem is that the size of the payload is too high.
You can fix this if you modify GetWiredMBusData -method like this.
This is only ad hoc for your problem. When you set this you can decrypt your data to XML values. I did try with C#.

//L-field.
int len = buff.GetUInt8();
int len2 = buff.GetUInt8();
if (len == 1)
{
len2 = len = 257;
}
//L-field.
if (len2 != len ||
.....

BR,
Mikko

Norbert

4 years 2 months ago

Hi Mikko

Hi Mikko

today I get this error:
Traceback (most recent call last):
File "p1decrypter_singergasse.py", line 104, in <module>
smarty_proxy.main()
File "p1decrypter_singergasse.py", line 65, in main
self.process()
File "p1decrypter_singergasse.py", line 85, in process
while translator.findNextFrame(msg, pdu):
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMSTranslator.py", line 195, in findNextFrame
found = GXDLMS.getData(settings, data, reply, None)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMS.py", line 2269, in getData
GXDLMS.__getWirelessMBusData(settings, reply, target)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMS.py", line 1114, in __getWirelessMBusData
man = _GXCommon.decryptManufacturer(manufacturerID)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/internal/_GXCommon.py", line 1810, in decryptManufacturer
return str(c2, c1, c)
TypeError: decoding str is not supported

but I don't know was the reason for the change. Any idea?
Thanks
Norbert

Profile picture for user Kurumi

Kurumi

4 years 2 months ago

Hi,

Hi,

Try with this:

t = GXDLMSTranslator()
t.pduOnly = True
t.completePdu = True
t.comments = True
t.authenticationKey = t.blockCipherKey = GXByteBuffer.hexToBytes("B829C67DC9DF3D9A81068540AD4C13E1")
data = GXByteBuffer("METER_DATA")
pdu = GXByteBuffer()
msg = GXDLMSTranslatorMessage()
msg.interfaceType = InterfaceType.WIRED_MBUS
msg.message = data
while t.findNextFrame(msg, pdu):
print(t.messageToXml(data))

BR,
Mikko

Norbert

4 years 2 months ago

Hi Mikko

Hi Mikko
same error:
File "p1decrypter_singergasse.py", line 91, in process
while t.findNextFrame(msg, pdu):
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMSTranslator.py", line 195, in findNextFrame
found = GXDLMS.getData(settings, data, reply, None)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMS.py", line 2269, in getData
GXDLMS.__getWirelessMBusData(settings, reply, target)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/GXDLMS.py", line 1114, in __getWirelessMBusData
man = _GXCommon.decryptManufacturer(manufacturerID)
File "/usr/local/lib/python3.7/dist-packages/gurux_dlms/internal/_GXCommon.py", line 1810, in decryptManufacturer
return str(c2, c1, c)
TypeError: decoding str is not supported

Thanks
Norbert

Profile picture for user Kurumi

Kurumi

4 years 2 months ago

Hi Norbert,

Hi Norbert,

Are you using the same message as in the first topic?
I tested the code using this message and it worked without problems.

I believe that you haven't set the used interface type and the translator expects that this is a Wireless MBus message.
msg.interfaceType = InterfaceType.WIRED_MBUS

BR,
Mikko

Norbert

4 years 1 month ago

Hi Mikko

Hi Mikko

I'm running this without compile errors, but no data for the message from the Sagemcom above.
A message from another meter, Kaifa from EVN too, will be converted successfully.
What is the different ?
Thansk, Norbert

def decryptSued(self, mySite, myKey, myMessage):
print('decryptSued ' + mySite + ' start...')
# use gurux_dlms package
translator = GXDLMSTranslator(TranslatorOutputType.SIMPLE_XML)
translator.comments = True
translator.completePdu = True
# set cipher key
translator.authenticationKey = translator.blockCipherKey = GXByteBuffer(myKey)
msg = GXDLMSTranslatorMessage()
msg.interfaceType = InterfaceType.WIRED_MBUS
msg.message = GXByteBuffer(myMessage)

xml = ""
pdu = GXByteBuffer()

while translator.findNextFrame(msg, pdu):
pdu.clear()
subXml = translator.messageToXml(msg)
print('decryptSued subXml ' + mySite + '>>>' + subXml)
xml += subXml
if msg.moreData == RequestTypes.NONE:
break

print('decryptSued xml ' + mySite + '>>>' + xml)
print('decryptSued ' + mySite + ' done.')

Norbert

4 years 1 month ago

Hi Mikko

Hi Mikko
want to come back to this topic, because I don't get it running. Yesterday I got another smartmeter, a Sagemcom T210-D, EVN. For example I get this:
<WiredMBus len="11" >
<TargetAddress Value="67" />
<SourceAddress Value="1" />
<PDU>
<Data="7860F474867E74AF" />
</PDU>
</WiredMBus>

Any idea, why this works for the Kaifa, but doesn't for the Sagemcom ?
Thanks, Norbert

Profile picture for user Kurumi

Kurumi

4 years 1 month ago

Hi Norbert,

Hi Norbert,

There is an issue in Sagemcom meter and because of that, the client can't parse the message. and the first frame is skipped.
http://www.gurux.fi/comment/23747#comment-23747

Ask if there is a firmware available where this is fixed. You can use the code I have shown above.

BR,
Mikko

Norbert

4 years 1 month ago

Hi Mikko

Hi Mikko
All right! I'm in contact with EVN...
Maybe you have a link to the specification of the M-Bus message / frame ?
Thanks,
Norbert

Profile picture for user Kurumi

Kurumi

4 years 1 month ago

Hi Norbert,

Hi Norbert,

M-Bus message is defined on DLMS standard. Problem is L-Field, length field, number of user data octets.¨

BR,
Mikko

Norbert

4 years 1 month ago

Hi Mikko

Hi Mikko
the issue is accepted by EVN, thanks for your support.
br
Norbert

Profile picture for user Kurumi

Kurumi

4 years 1 month ago

Hi Norbert,

Hi Norbert,

Thank you for letting me know about this. I hope that this is solved fast and you can start to read your meter.

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