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. Data Send Failed - Python_Raspberry PI

Data send failed - Python_Raspberry PI

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 Krzysztof S. , 23 December, 2020
Forums
Gurux.DLMS

Hello!

I have a problem with Gurux.DLMS for python on Raspberry PI 4.
I'd like to read data from meter Landis Gyr E650 using optical interface with USB. I connected USB to raspberry and I've done step by step your instructions for python Gurux.DLMS.

I check a connection meter Landis Gyr E650 and optical interface with USB on GXDLMSDriector (Windows10) and It works. I can read data.

My output of console is below.

python main.py -S /dev/ttyUSB0

gurux_dlms version: 1.0.95
gurux_net version: 1.0.17
gurux_serial version: 1.0.15
Authentication: Authentication.NONE
ClientAddress: 0x10
ServerAddress: 0x1
Standard: Standard.DLMS
Data send failed. Try to resend 1/3
Data send failed. Try to resend 2/3
RX: 10:12:44
DisconnectRequest
Traceback (most recent call last):
File "main.py", line 105, in main
reader.readAll(settings.outputFile)
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 508, in readAll
self.initializeConnection()
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 305, in initializeConnection
self.readDLMSPacket(data, reply)
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 117, in readDLMSPacket
self.readDLMSPacket2(data, reply)
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 167, in readDLMSPacket2
raise e
TimeoutException: Failed to receive reply from the device in given time.
Ended. Press any key to continue.

Please help with the problem :)

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

If you are using an optical probe you need to start communication using IEC 62056-21 Mode E. Try to add -i parameter.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

Thank you for your answer. I've added -i parameter but it doesnt work. I attach photo with a screen of console.

BR,
Krzysztof

Image

Krzysztof S.

5 years 5 months ago

My second photo is without -i

My second photo is without -i parameter.
Maybe it will help to understand the problem.

Please help :)

Image
Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

Please, add plain text it's easier to read than pics. Your meter didn't reply anything. Check that your serial port is correct. Remove optical probe and check that ttyUSB0 is not available anymore.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I've already checked serial port as you said and everything is correct. I know that the problem is with connection, but when I use GXDLMSDriector on Windows 10 I can read data.

Do you have any ideas what's next I can do?

Ok, sorry for photos. Next time I will send plain text. Unless you need text from above photos.

BR,
Krzysztof

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

Try to run python code in Windows and let me know what happened.

Can you share the information on what optical probe you are using? I did try with Kamstrup and EMH optical probes and I was able to read the meters without problems from the Pi.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I tried to run python code on Windows console but my serial port wasnt visible.

Available serial ports:
[]
Ended. Press any key to continue.

Using GXDLMSDriector application on Windows I can choose serial port and get data.

The optical probe is from a polish company Numeron - https://www.numeron.pl/urzadzenia/glowica-optyczna/
The company doesnt have an english language version of website.

I tried to run python code on PI several times and I got an answer from meter. I will paste it below.

python3 main.py -S /dev/ttyUSB3 -t Verbose -r sn
gurux_dlms version: 1.0.95
gurux_net version: 1.0.17
gurux_serial version: 1.0.15
Authentication: Authentication.NONE
ClientAddress: 0x10
ServerAddress: 0x1
Standard: Standard.DLMS
TX: 15:30:31 7E A0 07 03 21 93 0F 01 7E
RX: 15:30:31 7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E
TX: 15:30:31 7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 02 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 1C 03 20 FF FF 80 AB 7E
RX: 15:30:31 7E A0 2D 21 03 30 63 63 E6 E7 00 61 1F A1 09 06 07 60 85 74 05 08 01 02 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 06 04 04 0E 01 06 00 7E 79 7E
DisconnectRequest
TX: 15:30:31 7E A0 07 03 21 53 03 C7 7E
RX: 15:30:31 7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E
Connection is permanently rejected
No reason is given.
Ended. Press any key to continue.

BR,
Krzysztof

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I tried to run python code on another computer. The serial port was found and connected, but the problem is still the same as on PI.

Maybe there is a problem with the meter. I only connected the meter to a power supply and used my optical probe.

BR,
Krzysztof

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

Below I show logs from DXDLMSDirector. Maybe It will help with the problem.

GXDLMSDirector 8.2.2012.1701
Log created 21:05:05
System.ArgumentException: Element PortName nie może być pusty.
Nazwa parametru: PortName
w System.IO.Ports.SerialPort.set_PortName(String value)
w Gurux.Serial.GXSerial.set_PortName(String value)
w GXDLMSDirector.DevicePropertiesForm.AdvancedBtn_Click(Object sender, EventArgs e)
08:15:19 Initializing serial connection.
08:15:21 IEC Sending:/?!<CR><LF>
08:15:22 HDLC received: /LGZ5\2ZMD4104157.B32<CR><LF>
08:15:22 BaudRate is : 9600
08:15:22 Moving to mode E.
06 32 35 32 0D 0A
08:15:25 Send SNRM request.
7E A0 07 03 21 93 0F 01 7E
08:15:25
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E
08:15:25 Parsing UA reply succeeded.
08:15:25 Send AARQ request.
7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 02 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 1C 03 20 FF FF 80 AB 7E
08:15:25
7E A0 37 21 03 30 6C 7C E6 E7 00 61 28 A1 09 06 07 60 85 74 05 08 01 02 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 0F 04 0D 08 00 06 5F 1F 04 00 18 02 20 09 60 FA 00 0A A8 7E
08:15:25 Parsing AARE reply succeeded.
08:15:29 Read object type Register index: 1
7E A0 11 03 21 32 B7 3D E6 E6 00 05 01 02 04 48 04 3A 7E
08:15:29
7E A0 17 21 03 52 2B B3 E6 E7 00 0C 01 00 09 06 00 00 61 61 00 FF 7A 26 7E
08:15:29 Read object type Register index: 3
7E A0 11 03 21 54 87 3B E6 E6 00 05 01 02 04 58 85 2A 7E
08:15:29
7E A0 15 21 03 74 69 CE E6 E7 00 0C 01 00 02 02 0F 00 16 FF 4B C2 7E
08:15:29 Read object type Register index: 2
7E A0 11 03 21 76 97 39 E6 E6 00 05 01 02 04 50 CD A6 7E
08:15:29
7E A0 15 21 03 96 75 0A E6 E7 00 0C 01 00 09 04 02 00 00 00 40 91 7E
08:15:29 Read object type Register index: 1
7E A0 11 03 21 98 E7 37 E6 E6 00 05 01 02 48 A0 84 BE 7E
08:15:29
7E A0 17 21 03 B8 7F FB E6 E7 00 0C 01 00 09 06 00 00 60 F0 0C FF C4 40 7E
08:15:29 Read object type Register index: 3
7E A0 11 03 21 BA F7 35 E6 E6 00 05 01 02 48 B0 05 AE 7E
08:15:29
7E A0 15 21 03 DA 1D 82 E6 E7 00 0C 01 00 02 02 0F 00 16 FF 4B C2 7E
08:15:29 Read object type Register index: 2
7E A0 11 03 21 DC C7 33 E6 E6 00 05 01 02 48 A8 CC 32 7E
08:15:29
7E A0 11 21 03 FC C5 B4 E6 E7 00 0C 01 00 11 4F 9B DE 7E
08:15:29 Read object type Clock index: 1
7E A0 11 03 21 FE D7 31 E6 E6 00 05 01 02 2B C0 BF 92 7E
08:15:29
7E A0 17 21 03 1E 43 3B E6 E7 00 0C 01 00 09 06 00 00 01 00 00 FF 0F E0 7E
08:15:29 Read object type Clock index: 2
7E A0 11 03 21 10 A7 3F E6 E6 00 05 01 02 2B C8 F7 1E 7E
08:15:30
7E A0 1D 21 03 30 91 2F E6 E7 00 0C 01 00 09 0C 07 D0 01 07 05 17 15 39 FF 80 00 01 D3 E2 7E

...cd

BR,
Krzysztof

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

You need to give -i parameter. I believe it's the reason.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I've added -i parameter but It doesn't work. Please for advice.
Below is text from PI console after this operation.

python3 main.py -S /dev/ttyUSB7 -i -t Verbose

gurux_dlms version: 1.0.95
gurux_net version: 1.0.17
gurux_serial version: 1.0.15
Authentication: Authentication.NONE
ClientAddress: 0x10
ServerAddress: 0x1
Standard: Standard.DLMS
TX: 12:38:49 /?!

DisconnectRequest
Traceback (most recent call last):
File "main.py", line 105, in main
reader.readAll(settings.outputFile)
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 508, in readAll
self.initializeConnection()
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 301, in initializeConnection
self.initializeOpticalHead()
File "/home/pi/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 198, 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.

BR,
Krzysztof

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I check my serial port communication on Windows using an application for COM monitoring. A screen of the operation is below.

I sent /?! and got the answer. I think something is wrong with the python library if I'd like to use an optical probe.

Maybe you have some advice?
Thanks for help.

BR,
Krzysztof

Image
Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

Can you see if the Pi app is sending <CR><LF> after "/?!"? The meter should reply and now there is nothing.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I've checked it during runing python code on Windows. The app sent <CR><LF> after "/?!", but there was no reply from meter.

But Biatel COM Monitor which I sent the image above was able to communicate with meter and get data.

Any ideas what's next?

BR,
Krzysztof

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

Try with this:
python3 main.py -S /dev/ttyUSB7:300:7Even1 -i -t Verbose

The client example is also modified so 300:7Even1 is the default serial port setting when IEC Mode E is used.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

Biatel application is using IEC 62056-21 readout mode and not DLMS.

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

I've already realized your idea, but It doesn't work :(

BR,
Krzysztof

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

And you are running this?
python3 main.py -S /dev/ttyUSB7 -i -t Verbose

You must use -i parameter!

Are you getting any reply from the meter?

BR,
Mikko

Krzysztof S.

5 years 5 months ago

Hi,

Hi,

Yes, I've runned your instruction with -i parameter, but It doesn't work.

I don't have more time to get know the library, so I've writed my own script with pyserial library to read data from the meter and It works.
I've used your instruction from website http://www.gurux.fi/DLMSIntro how to communicate with the meter and everything is fine. In my project I only need data from registers of the meter.
My python script works, so It is the end :)

Thank for your time and help Mikko.

BR,
Krzysztof

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

HI,

HI,

I'm glad if IEC 62056-21 readout fills your needs and you don't need DLMS.
It's much easier in this way.

BR,
Mikko

Toni

5 years 4 months ago

Dear Krzysztof,

.

  • 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