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. Directly Reading An OBIS Code Seems To Be Not Working [C++]

Directly reading an OBIS code seems to be not working [C++]

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 amjaber , 19 April, 2018
Forums
General discussion

Hello,

I am using you C++ implementation to read some DLMS meters I have around. I can read an OBIS code with FindByLn successfully, but not without it. Here a snippet of the code I am using for the both cases:

if ((ret = comm.InitializeConnection()) == 0
&& (ret = comm.GetAssociationView()) == 0)
{
std::string reply;
CGXDLMSRegister r("0.0.1.0.0.255");
objectsToRead = "0.0.1.0.0.255";
// objectsToRead = "1.0.9.8.7.255"; // voltage from Standards OBIS codes
CGXDLMSObject o(DLMS_OBJECT_TYPE_ALL, objectsToRead);
std::cout << "Reading directly:" << "\n";
if ( (ret = comm.Read(&o, 3, reply)) == DLMS_ERROR_CODE_OK) {
std::cout << "reply: " << reply << "\n";
} else {
std::cout << "ret: " << ret << "\n";
}
if ( (ret = comm.Read(&o, 2, reply)) == DLMS_ERROR_CODE_OK) {
std::cout << "reply: " << reply << "\n";
} else {
std::cout << "ret: " << ret << "\n";
}

std::cout << "\n";
// Using FindByLN
CGXDLMSObject* obj = cl.GetObjects().FindByLN(DLMS_OBJECT_TYPE_ALL, objectsToRead);
std::cout << "Reading with FindByLn:" << "\n";
if ( (ret = comm.Read(obj, 3, reply)) == DLMS_ERROR_CODE_OK) {
std::cout << "reply: " << reply << "\n";
} else {
std::cout << "ret: " << ret << "\n";
}
if ( (ret = comm.Read(obj, 2, reply)) == DLMS_ERROR_CODE_OK) {
std::cout << "reply: " << reply << "\n";
} else {
std::cout << "ret: " << ret << "\n";
}
}

And here is the output:
InitializeConnection
GetAssociationView
Reading directly:
ret: 9
ret: 9

Reading with FindByLn:
reply: 180
reply: 4/19/2018 09:31:55

May you please help me figure it out? I want to read directly because it will be faster than using GetAssociationView before reading, as GetAssociationView takes some time.

Thanks in advance

Profile picture for user Kurumi

Kurumi

8 years 3 months ago

Directly reading an OBIS code seems to be not working [C++]

Hi,

You did not tell what you want to read, but you need to define object type and OBIS code.
If they are right meter reply error. For this reason you can't use DLMS_OBJECT_TYPE_ALL when you read
data from the meter. You can use it to find item by OBIS code.

Something like this:

CGXDLMSRegister r("1.0.9.8.7.255");

comm.Read(&o, 3, reply);

BR,
Mikko

amjaber

8 years 3 months ago

Thank you very much, I used

Thank you very much, I used CGXDLMSRegister before but it gave segmentation fault, I thought it was not working, it turn out I have used a wrong OBIS code, Now CGXDLMSRegister works for all the registers I want to read. Thank you again and sorry for my silly mistake.

Best Regards,
Abdulrahman

Profile picture for user Kurumi

Kurumi

8 years 3 months ago

Directly reading an OBIS code seems to be not working [C++]

Hi,

Thank you for let me know that you solved it.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Possible memory leak in file dlms.c, getCompactArrayItem(), getCompactArrayItem2()
  • Official Gurux.DLMS.Client.Example.Net fails during High GMAC secure association (Invalid PDU), while Gurux Director connects successfully
  • gurux_dlms.GXDateTime.GXDateTime object Error in Python
  • T_APPL_DATA_LN_N1 subtest 3 fails on an LN-only server regardless of the response to a non-existing-object GET
  • Version mismatch between Gurux.DLMS 9.x and Gurux.Common/Gurux.Serial 8.x
More

Who's new

  • Kennetharrem
  • xyBvBjRVwiYVQggL
  • RobertCon
  • JamesLef
  • Bryoneverb
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin