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. MY AMR Sample Application Is Crashing, When I Read Data of The Profile-object From The Meter Again.

MY AMR sample application is crashing, when I read data of the profile-object from the meter again.

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 pradson , 15 February, 2021
Forums
Gurux.DLMS

Hi Mikko,

My question is regarding reading of profile-objects(Instantaneous, block, daily, events profile):

Step-1
I create the objects of "CGXCommunication" and "CGXDLMSSecureClient" and make a connection with meter. I create a profile-object and read the capture objects first, then read data. It works no issue.

Step-2
I close the connection with the meter and delete the objects of "CGXCommunication" and "CGXDLMSSecureClient".

Step-3
I create the new objects of "CGXCommunication" and "CGXDLMSSecureClient" again and make a connection with meter. I have a profile-object which I have created and read earlier. This profile-object has capture object related details. That's why I will not read capture objects again. Now, whenever I read the data from the meter, then It crashes. In this case, Will I have to read capture object at every connection?

My requirement is that I want to read capture-objects only once and store it into a file for future use.
I do not want to read it again and again. Is this possible?

Kindly check my sample code and suggest me why is it crashing?

#############################################################################
############################# Sample Code #####################################
#############################################################################

///////////////////////// Create Connection here /////////////////////////////////////
int ret=0;
CGXDLMSSecureClient *m_DLMSclient = NULL;
m_DLMSclient = new CGXDLMSSecureClient(true, 32, 19, DLMS_AUTHENTICATION_LOW, "admin01", DLMS_INTERFACE_TYPE_WRAPPER);
m_DLMSclient->SetUseUtc2NormalTime(true);

CGXCommunication *m_pCGXCommunication = NULL;
m_pCGXCommunication = new CGXCommunication(m_DLMSclient, 5000, GX_TRACE_LEVEL_INFO, NULL);
if ((ret = m_pCGXCommunication->Connect("192.168.0.3", 4059)) != 0) {
printf("Couldn't connect to the device... %s.\r\n", CGXDLMSConverter::GetErrorMessage(ret));
}
if ((ret = m_pCGXCommunication->InitializeConnection()) != 0) {
printf("Connection initialization failed %s.\r\n", CGXDLMSConverter::GetErrorMessage(ret));
m_pCGXCommunication->Close();
m_pCGXCommunication->Release();
return 0;
}

///////////////////////// Create a profile generic object here /////////////////////////////////////
CGXDLMSProfileGeneric *objIP = new CGXDLMSProfileGeneric("1.0.94.91.0.255");
ret = 0;
std::string sValues;

///////////////////////// Read capture objects of profile generic object here /////////////////////////////////////
if ((ret = m_pCGXCommunication->Read(objIP, 3, sValues)) != 0)
{
printf("err! failed to readCaptureObjects: %s \n", CGXDLMSConverter::GetErrorMessage(ret));
}

///////////////////////// Read dataof profile generic object here /////////////////////////////////////
sValues.clear();
if ((ret = m_pCGXCommunication->Read(objIP, 2, sValues)) != 0)
{
printf("err! failed to values: %s \n", CGXDLMSConverter::GetErrorMessage(ret));
}

///////////////////////// close the connection here /////////////////////////////////////
m_pCGXCommunication->Close();
m_pCGXCommunication->Release();

///////////////////////// delete the communication and client object here /////////////////////////////////////
delete m_pCGXCommunication;
m_pCGXCommunication = NULL;

delete m_DLMSclient;
m_DLMSclient = NULL;

///////////////////////// Again create Connection with same parameters here /////////////////////////////////////
if (m_DLMSclient == NULL) {
m_DLMSclient = new CGXDLMSSecureClient(true, 32, 1, DLMS_AUTHENTICATION_LOW, "admin01", DLMS_INTERFACE_TYPE_WRAPPER);
m_DLMSclient->SetUseUtc2NormalTime(true);
}

if (m_pCGXCommunication == NULL)
{
m_pCGXCommunication = new CGXCommunication(m_DLMSclient, 5000, GX_TRACE_LEVEL_INFO, NULL);
}

if ((ret = m_pCGXCommunication->Connect("192.168.0.3", 4059)) != 0) {
printf("Couldn't connect to the device... %s.\r\n", CGXDLMSConverter::GetErrorMessage(ret));
}
if ((ret = m_pCGXCommunication->InitializeConnection()) != 0) {
printf("Connection initialization failed %s.\r\n", CGXDLMSConverter::GetErrorMessage(ret));
m_pCGXCommunication->Close();
m_pCGXCommunication->Release();
return 0;
}

///////////////////////// Read Capture objects not needed as I have read it earlier /////////////////////////////////////

///////////////////////// Now read data of profile generic object here /////////////////////////////////////
sValues.clear();
if ((ret = m_pCGXCommunication->Read(objIP, 2, sValues)) != 0) // <<<<------ crash point is here
{
printf("err! failed to values: %s \n", CGXDLMSConverter::GetErrorMessage(ret));
}
m_pCGXCommunication->Close();
m_pCGXCommunication->Release();
return 0;
##############################################################################

Thanks & Regards,
Pradson

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi,

Hi,

Client example does what you want to do. If you give -o association is saved to the file.
When you destroy the client it will clear the objects and you try to use objects later. I believe that is the problem here.

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