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. InterCharachterTimeout

interCharachterTimeout

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 fon Luck , 2 June, 2022
Forums
Gurux.DLMS

Hello!

Dlms.c, server.c, function svr_handle Request 2().

Checking frame using inter Character Timeout:
uint32_t now = time_elapsed();
uint16_t elapsed = (uint16_t)(now - settings->frame Received) / 1000;

Dividing by 1000 gives measurement of seconds. How far i understand it must be in milliseconds.

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

That is used to count Inactivity time out. The connection is closed if the client doesn't send any frames in a given time. Inter octet time out can be implemented where bytes are read from the UART.

https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSIecHdlcSetup

BR,
Mikko

fon Luck

4 years ago

Hello!

Hello!
Function svr_handle Request 2() collects packages, not only analyze its.
Full code :

//Check frame using inter Charachter Timeout.
#if !defined(DLMS_IGNORE_HDLC) || !defined(DLMS_IGNORE_IEC_HDLC_SETUP)
if (IS_HDLC(settings->base.interfaceType) && settings->hdlc != NULL && settings->hdlc->interCharachterTimeout != 0)
{
uint32_t now = time_elapsed();
uint16_t elapsed = (uint16_t)(now - settings->frameReceived) / 1000;
//If frame shoud be fully received.
if (elapsed >= settings->hdlc->interCharachterTimeout)
{
settings->receivedData.position = settings->receivedData.size = 0;
}
settings->frameReceived = now;
}
#endif //!defined(DLMS_IGNORE_HDLC) || !defined(DLMS_IGNORE_IEC_HDLC_SETUP)

Analyzed the variable "inter Character Timeout ". From https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSIecHdlcSetup :
"7 Inter octet time out.
How long meter will wait new bytes before it thinks that total frame is received. Value is given in milliseconds."

Inactivity Timeout checked later.

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hello,

Hello,

The inactivity time out is read from the wrong attribute. I created an issue from this. The new version is released where this is fixed.
https://www.gurux.fi/node/19962

Thank you for pointing this out.

BR,
Mikko

fon Luck

4 years ago

Hello!

Hello!
You wrote: "Inter octet timeout can be implemented where bytes are read from the UART."
The function svr_handle Request 2() build frame from received bytes. To implement your recommendation need function, that will be analyze frame at once without collecting bytes.

Example:
UART receive bytes and store in buffer.
After inter octet timeout this buffer sending to server.
If frame in buffer is completed, then server handle it, else drop it. Or answering with some error code?

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

Inter octet timeout doesn't analyze the received bytes.
Your idea in your example is correct.

inter_octet_time_out is a wait time that defined how long UART waits for new bytes. If HDLC frame is correct it's handled or skipped if it's invalid (For example the CRC is invalid or inactivity_time_out has elapsed).

BR,
Mikko

fon Luck

4 years ago

Hello!

Hello!
My suggestion:
In gxignore.h add row :
#define DLMS_IGNORE_INCOMPLETE_FRAME

In the function dlms_getData2() of file dlms.c make change:
// If all data is not ready yet.
if (!data->complete)
{
#ifdef DLMS_IGNORE_INCOMPLETE_FRAME // add
return DLMS_ERROR_CODE_WRONG_CRC; // add
#endif //add
return 0;
}

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

There are multiple reasons why complete might be false. For example, all the frame bytes are not received. Your proposal also doesn't pass DLMS conformance tests.

This will also cause problems for example an RS-485 bus there are multiple meters on the same bus. If a frame is not targetted for the meter it must be skipped.

BR,
Mikko

fon Luck

4 years ago

Hello!

Hello!
In the function svr_handle Inactivity Timeout() of server.c handled inactivity timeout for DLMS connection.
if (settings->info.preEstablished || (settings->base.connected & DLMS_CONNECTION_STATE_DLMS) != 0) {}
Are inactivity timeout for HDLC connection handled?

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hello,

Hello,

Inactivity timeout is handled in svr_handleRequest method. Our clients have passed the DLMS CTT tests and HDLC Inactivity timeout is part of the tests.

BR,
Mikko

fon Luck

4 years ago

Hello!

Hello!
I do not doubt, that Your library have passed the DLMS CTT tests.
I have problem in next situation:
1) Open COM port, send SNRM to SAP = 1 of Gurux server, receive UA. Close COM port without DISC. (Like program crash.)
2) Open COM port, send SNRM to SAP = 0x10 and do not receive any answers.

After first SNRM frame, server address (with SAP) stored to settings->serverAddress in function dlms_checkHdlcAddress().
And DLMS_CONNECTION_STATE_HDLC stored to settings->base.connected.

Second SNRM received with other server address and do not pass check in same function.
Inactivity timeout checked aftet calling dlms_getData2() -> dlms_getHdlcData().

Periodic checking of inactivity timeout in svr_handleInactivityTimeout() work only with DLMS connection
if (settings->info.preEstablished || (settings->base.connected & DLMS_CONNECTION_STATE_DLMS) != 0) {}

With best regards.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

That works like expected. You have to wait until the Inactivity timeout has elapsed before the server can accept the next connection.

If you wait for Inactivity timeout time you can connect again.

BR,
Mikko

fon Luck

3 years 12 months ago

Hello!

Hello!
I'm sorry, maybe I didn't describe the situation clearly enough. I can't connect to another SAP after the inactivity timeout has expired. Because the inactivity timeout check in svr_handle inactivityTimeout() is performed only to connect to DLMS or after checking the frame in dlms_getHdlcData(). But the frame for another SAP is rejected and the idle timeout is not checked.

With best regards.

Profile picture for user Kurumi

Kurumi

3 years 12 months ago

Hi,

Hi,

Just to clarify. The steps are:
1. Connect for the meter using SAP 1.
2. Wait until the inactivity timeout has expired.
3. Reconnect for the meter using SAP 2 and this fails.

BR,
Mikko

fon Luck

3 years 12 months ago

Hello!

Hello!
Exactly.
Need point, that DLMS_CONNECTION_STATE_HDLC stored to settings->base.connected.

With best regards.

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

I'll check this and get back to this topic as soon as I have more information.

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