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. Reading Serial Port Issue

Reading serial port issue

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 sirodriguezr , 12 May, 2017
Forums
Gurux.Serial

Hi,

I am working with GuruxDLMSClientExample (ANSI C++ version) in Linux. During the execution of the program I get the following:

InitializeConnection
<- 13:01:38 7E A0 08 02 23 03 93 3E 74 7E
SNRMRequest failed 252.
InitializeConnection failed Data send failed...

It seems that the ReadDataBlock is the problem but I do not really know what can I do to initialize the reading.

The serial port /dev/tyUSB0 gets ~�##s�H����j~, so the meter (SL7000) is sending data. Actually, the phone image in the meter's display is active when the program is running.

I would like to ask for some advice on this issue.

I really appreciate any help you can provide.

Best regards
Santiago

Profile picture for user Kurumi

Kurumi

9 years 1 month ago

Reading serial port issue

Hi,

What settings you are using? Baudrate, databits, parity, stopbits?

BR,
Mikko

sirodriguezr

9 years 1 month ago

Reading serial port issue

Hi Mikko,

I started with default serial port settings [Baudrate (9600), databits (8), parity (N), stopbits (1)],

m_hComPort = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
// 8n1, see termios.h for more information
options.c_cflag = CS8 | CREAD | CLOCAL;

//Set Baud Rates
cfsetospeed(&options, B9600);
cfsetispeed(&options, B9600);

options.c_cc[VMIN] = 1;
//How long we are waiting reply charachter from serial port.
options.c_cc[VTIME] = m_WaitTime / 1000;

tcsetattr(m_hComPort, TCSAFLUSH, &options

I have been doing some test and when I disable O_NONBLOCK option the reading works but what I received it does not make any sense, here it is the trace

InitializeConnection
<- 09:59:26 7E A0 08 02 23 03 93 3E 74 7E
-> 09:59:26 7E 00 00 00 00 00 00 00 00 00
<- 09:59:26 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 41 42 43 44 45 46 47 48 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF 3B C3 7E
-> 09:59:26 7E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GetAssociationView

Thank you for your attention to this matter.

Best regards,
Santiago

Profile picture for user Kurumi

Kurumi

9 years ago

Reading serial port issue

Hi,

It seems that you are reading only first byte and rest are zeros. Are you reading data until end of packet?

BR,
Mikko

sirodriguezr

9 years ago

Reading serial port issue

Hi,

I do not think the program is doing that (reading data until the end of packet). In fact, it seems that after reading the first byte it only gets zeros. I have tried different serial port configurations but none of them had worked.

This is the trace result,

InitializeConnection
<- 10:38:09 7E A0 08 02 23 03 93 3E 74 7E
-> 10:38:09 7E 00 00 00 00 00 00 00 00 00
<- 10:38:09 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 41 42 43 44 45 46 47 48 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF 3B C3 7E
-> 10:38:09 7E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GetAssociationView
<- 10:38:09 7E A0 1A 02 23 03 32 75 62 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E
-> 10:38:11 7E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
<- 10:38:11 7E A0 08 02 23 03 51 20 91 7E
-> 10:38:11 7E 00 00 00 00 00 00 00 00 00
<- 10:38:11 7E A0 08 02 23 03 71 22 B0 7E
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Aborted (core dumped)

Thank you for your attention to this matter.

Best regards,
Santiago

Profile picture for user Kurumi

Kurumi

9 years ago

Reading serial port issue

Hi,

Try to change this to:
options.c_cc[VTIME] = 5;

Let me know if that helped.

BR,

Mikko

sirodriguezr

9 years ago

Reading serial port issue

Hi,

I followed your recommendation, but the problem persists.

Sincerely,
Santiago

Profile picture for user Kurumi

Kurumi

8 years 12 months ago

Reading serial port issue

Hi Santiago,

We have made some changes for the example. Try to get latest version and let me know if you still have problems. Please, let me know you distro and brand of your USB converter.

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