Failure in Disconnect Request

Project: 
gurux.dlms.cpp

I was sending a disconnect command by method 'CGXDLMSClient::DisconnectRequest', but nothing happened. I noticed that disconnect command should be sent only if DLMS_CONNECTION_STATE_HDLC is defined.

I believe that this flag must be set up when my app (client side) send an SNRM message in method 'CGXDLMSClient::SNRMRequest'.

I change this method from

ret = CGXDLMS::GetHdlcFrame(m_Settings, DLMS_COMMAND_SNRM, &data, reply);
packets.push_back(reply);

to

ret = CGXDLMS::GetHdlcFrame(m_Settings, DLMS_COMMAND_SNRM, &data, reply);
m_Settings.SetConnected(DLMS_CONNECTION_STATE_HDLC);
packets.push_back(reply);

and disconnect command is been sent as I expected.

I would like to know if my comments make sense. Thanks.

Status: 
Closed (fixed)
Priority: 
Major
Category: 
Bug report
Component: 
Code
Reporter: 
Evandro Padrao ...
Created: 
Wed, 01/16/2019 - 19:22
Updated: 
Thu, 01/17/2019 - 09:11

Comments

Evandro Padrao Carvalho de Aguiar's picture

Checking the "Gurux DLMS library for ANSI C", the flag DLMS_CONNECTION_STATE_HDLC is set up in the function "cl_parseUAResponse".

Then, I believe that this flag should be set up in the method "CGXDLMS::SNRMRequest". And this flag must be removed in the method "CGXDLMSClient::DisconnectRequest".

Kurumi's picture

Hi,

You are right. ANSI C++ is not HDLC flag, but it's set on ParseUAResponse. The reason is that connection to the HDLC is not set when SNRMRequest is called. This is fixed and the new version is released.

BR,
Mikko

Kurumi's picture

Status: Active » Closed (fixed)
Evandro Padrao Carvalho de Aguiar's picture

For me sound strange the HDLC flag is set on ParseUAResponse because when 'client side' sends a 'Disconnect Request' (code 0x53) I believe that the HDLC flag must be reset. But, the meter responses a 'UA Request' (code 0x73) and if the 'client side' evaluates the response by ParseUAResponse the HDLC flag will be set again.

Kurumi's picture

Hi Evandro,

This is done because if the meter doesn't accept the client we don't want to send the release.
For this reason, HDLC flag is set on ParseUAResponse.

You are right that HDLC flag should be clear on DisconnectRequest.

We'll change this. New version is released today.

BR,
Mikko

Roberto Sánchez's picture

Hi Mikko,
I was testing the connection and disconnection comand over the relay OBIS(0.0.96.3.10.255). The Java code is:

GXDLMSDisconnectControl relay = new GXDLMSDisconnectControl("0.0.96.3.10.255");
byte[][] data = relay.remoteReconnect(dlms_client);
GXReplyData r = new GXReplyData();
readDataBlock(data, r);

At the begining it was not working, but after doing some research I realize that one part in the code was causing an error in my data packet. This part of the code is in GXDLMSClient class, in the function:
public final byte[][] method(final Object name, final ObjectType objectType,
final int methodIndex, final Object value,
final DataType dataType)

In the process of buiding the trace for UseLogicalNameReferencing, one can find the calc. for CI, LN, Attribute ID an then there is a section that says: "// Method Invocation Parameters is not used." and the code below, was causing the error in my trace:

if (type == DataType.NONE) { attributeDescriptor.setUInt8(0); }
else { attributeDescriptor.setUInt8(1);}

I deleted this part and now, the command is working as I expected. My question: Is this code valid for some kind of meters, or is this a bug?

Thanks for your help.

Kurumi's picture

Hi,

This is used for several different meters. Standard says clearly that there is data. If your meter can't handle remoteReconnect where is data part there is an error on the meter.

From Blue Book:
remote_reconnect
data ::= integer (0)

BR,
Mikko