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