Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. Keep-alive message is not working

Keep-alive message is not working

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 Adonay Eshetu, 29 December, 2022
Forums
Gurux DLMS for Java

Hello Mikko,

I hope the holidays went well. I was implementing a client application and I don't want my client to timeout because of the meter's timeout time setted. So what I am trying is sending a keepalive message to the meter before it times out and closes the connection.

But when I do that without making any modifications to gurux.dlms package, only by calling the keepAlive method in the GXDLMSClient class, it throws an exception and just closes the connection and I can not send a message after that.

Here is the bytes sent for keep alive as a request and received response.
-> 7E A0 08 02 21 09 B1 E6 3E 7E
<- 7E A0 08 09 02 21 B1 5F FF 7E
and the connection times out after that and throws an exception.

So I looked into the GXDLMSClient class, keepAlive() method and it is not calling the getKeepAlive() method of the GXDLMSSettings class, rather it is calling the getRecieverReady() method.

public final byte[] keepAlive() {
// There is no need for keep alive in IEC 62056-47.
if (this.getInterfaceType() == InterfaceType.WRAPPER) {
return new byte[0];
}
return GXDLMS.getHdlcFrame(settings, settings.getReceiverReady(), null);
}

I don't know if you have done that on purpose or if it was an error so I changed the implementation of the method to the below code and recompiled and packaged it again and used it.

public final byte[] keepAlive() {
// There is no need for keep alive in IEC 62056-47.
if (this.getInterfaceType() == InterfaceType.WRAPPER) {
return new byte[0];
}
return GXDLMS.getHdlcFrame(settings, settings.getKeepAlive(), null);
}

Changed only settings.getReceiverReady() to settings.getKeepAlive(). Now the connection doesn't timeout but I am facing a header CRC problem in the requests I send to the meter after the keepalive is performed.

Below is the byte that is sent as a keepalive request and the received reply from the meter.

-> 7E A0 08 02 21 09 B1 E6 3E 7E
<- 7E A0 08 09 02 21 D1 59 9C 7E

After the above request and response, the client changes the header CRC of the request messages generated and send to the meter and causing a checksum problem.

Here are the bytes that I generated to read the same object before and after keep-alive is sent to the meter.

before keepalive request, I was able to read from the meter with this request
-> 7E A0 1A 02 21 09 BA FD 22 E6 E6 00 C0 01 C1 00 01 00 00 60 02 0C FF 02 00 71 2A 7E

after keepalive request, the header CRC of the read request is changed and I can not read from the meter, it causes a checksum error
-> 7E A0 1A 02 21 09 DC CD 24 E6 E6 00 C0 01 C1 00 01 00 00 60 02 0C FF 02 00 71 2A 7E

I did not change any inputs or parameters in between requests.

I can not figure out why it is changing the header CRC and I am not sure if I should keep using the keepalive method of the GXDLMSClient class with settings.getReceiverReady() or settings.getKeepAlive() method.

If you please help me figure out what is happening here I would appreciate it.
Thank you in advance.

Sincerely,
Adonay Eshetu

Profile picture for user Kurumi

Kurumi

2 months 4 weeks ago

Hi Adonay,

Hi Adonay,
The header checksum is changed because the HDLC sequence number is updated.

All the meters don't support HDLC keepalive. For that reason, we aren't using it anymore.

I propose that you read the logical name of the association view as a keep alive. It'll work with all the meters. Something like this:

GXDLMSAssociationLogicalName item = new GXDLMSAssociationLogicalName();
Read(item, 1);

BR,
Mikko

Adonay Eshetu

2 months 3 weeks ago

Hi Mikko,

Hi Mikko,

Thank you for the help, It is working fine now.

Sincerely,
Adonay Eshetu

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

Fri, 03/24/2023 - 14:22
gurux.dlms.c 20230324.1
Thu, 03/23/2023 - 11:01
GXDLMSDirector 9.0.2303.2301
Thu, 03/23/2023 - 09:10
Gurux.DLMS.Python 1.0.142
Wed, 03/22/2023 - 13:51
Gurux.DLMS.Net 9.0.2303.2201
Wed, 03/22/2023 - 10:15
gurux.dlms.c 20230322.1

Open bugs

Gurux.DLMS.AMI4
1
Gurux.DLMS.Android
1
gurux.dlms.c
3
gurux.dlms.cpp
3
gurux.dlms.delphi
1
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin