Reading serial port issue

8 posts / 0 new
Last post
sirodriguezr
Reading serial port issue

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

kurumi
kurumi's picture
Reading serial port issue

Hi,

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

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
Hermiankatu 6-8 H 33720 TAMPERE, FINLAND
Phone: +358 3 265 1244
Home page: http://www.gurux.org

sirodriguezr
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

kurumi
kurumi's picture
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

________________________________________
Mikko Kurunsaari
Gurux Ltd
Hermiankatu 6-8 H 33720 TAMPERE, FINLAND
Phone: +358 3 265 1244
Home page: http://www.gurux.org

sirodriguezr
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

kurumi
kurumi's picture
Reading serial port issue

Hi,

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

Let me know if that helped.

BR,

Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
Hermiankatu 6-8 H 33720 TAMPERE, FINLAND
Phone: +358 3 265 1244
Home page: http://www.gurux.org

sirodriguezr
Reading serial port issue

Hi,

I followed your recommendation, but the problem persists.

Sincerely,
Santiago

kurumi
kurumi's picture
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

________________________________________
Mikko Kurunsaari
Gurux Ltd
Hermiankatu 6-8 H 33720 TAMPERE, FINLAND
Phone: +358 3 265 1244
Home page: http://www.gurux.org