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.
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."
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
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?
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).
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;
}
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.
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?
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.
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) {}
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.
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
Hello!
Hello!
Exactly.
Need point, that DLMS_CONNECTION_STATE_HDLC stored to settings->base.connected.
With best regards.
Hi,
Hi,
I'll check this and get back to this topic as soon as I have more information.
BR,
Mikko