Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Reading Billing Date

Reading Billing Date

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 poojash, 29 November, 2021
Forums
Known problems

Hi,
I am trying to read Billing date from meter but i get error "Read object Failed".
TX: 7E:A0:19:03:41:32:3A:BD:E6:E6:00:C0:01:81:00:03:00:00:00:01:02:FF:02:00:B1:48:7E
RX: 7E:A0:1E:41:03:52:05:4F:E6:E7:00:C4:01:81:00:09:0C:07:E5:0B:01:01:00:00:00:FF:80:00:00:F1:3A:7E

using Gurux director i can see value received,
<Data>
<!--2021-11-01 00:00:00-->
<OctetString Value="07E50B0101000000FF800000" />

But using coding how i can call using variable. Following is code for that

int Read_BillingDate(void)
{
gxRegister BillingDate;
int ret;
char BillingDatesamp1e[]="2021-11-01 00:00:00";
const unsigned char lnc[6] = { 0,0,0,1,2,255};
ret = INIT_OBJECT(BillingDate, DLMS_OBJECT_TYPE_REGISTER, lnc);
{
GX_OCTECT_STRING(BillingDate.value, BillingDatesamp1e,sizeof(BillingDatesamp1e));
}
ret = com_read(&BillingDate.base, 2);
if (ret != DLMS_ERROR_CODE_OK)
{
printf("Read Error\n\r");
return ret;
}

printf("BillingDateRead complete\n\r");
printf("BillingDate: %s\n\r",BillingDate.value.pbVal);
return 0;
}

How I get value using BillingDate.value.pbVal

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

Your meter is returning Billing Date as an octetString. You need to change it from byte array to date-time like this:

int Read_BillingDate(void)
{
gxRegister BillingDate;
int ret;
unsigned char BillingDatesamp1e[12] = { 0 };
const unsigned char lnc[6] = { 0,0,0,1,2,255 };
if ((ret = INIT_OBJECT(BillingDate, DLMS_OBJECT_TYPE_REGISTER, lnc)) == 0)
{
GX_OCTECT_STRING(BillingDate.value, BillingDatesamp1e, sizeof(BillingDatesamp1e));
ret = com_read(BASE(BillingDate), 2);
if (ret != DLMS_ERROR_CODE_OK)
{
printf("Read Error\n\r");
return ret;
}
dlmsVARIANT date;
var_init(&date);
cl_changeType(BillingDate.value.byteArr, DLMS_DATA_TYPE_OCTET_STRING, &date);
printf("BillingDateRead complete\n\r");
char str[20];
time_toString2(date.dateTime, str, sizeof(str));
printf("BillingDate: %s\n\r", str);
var_clear(&date);
obj_clear(&BillingDate);
}
return 0;
}

BR,
Mikko

poojash

3 years 5 months ago

I got this error after adding

I got this error after adding above code you given,
error: 'dlmsVARIANT {aka struct tagdlmsVARIANT}' has no member named 'dateTime'
time_toString2(date.dateTime, str, sizeof(str));

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

OK. You are not using malloc. Use this:

int Read_BillingDate(void)
{
gxRegister BillingDate;
int ret;
unsigned char BillingDatesamp1e[12] = { 0 };
const unsigned char lnc[6] = { 0,0,0,1,2,255 };
if ((ret = INIT_OBJECT(BillingDate, DLMS_OBJECT_TYPE_REGISTER, lnc)) == 0)
{
GX_OCTET_STRING(BillingDate.value, BillingDatesamp1e, sizeof(BillingDatesamp1e));
ret = com_read(BASE(BillingDate), 2);
if (ret != DLMS_ERROR_CODE_OK)
{
printf("Read Error\n\r");
return ret;
}

dlmsVARIANT tmp;
gxtime billlingDate;
time_initUnix(&billlingDate, 0);
GX_DATETIME(tmp) = &billlingDate;
gxByteBuffer bb;
BB_ATTACH(bb, BillingDatesamp1e, 12);
if ((ret = dlms_changeType(&bb, DLMS_DATA_TYPE_DATETIME, &tmp)) == 0)
{
printf("BillingDateRead complete\n\r");
char str[20];
time_toString2(&billlingDate, str, sizeof(str));
printf("BillingDate: %s\n\r", str);
}
var_clear(&tmp);
obj_clear(&BillingDate);
}
return 0;
}
BR,
Mikko

poojash

3 years 5 months ago

hi,

hi,
Now getting "undefined reference to `time_toString2'" this error. since I included data.h file

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

You need to also add data.c -file.

BR,
Mikko

poojash

3 years 5 months ago

I dont have data.c file'

I dont have data.c file'

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Sorry,

Sorry,

You need to also add date.c -file.

BR,
Mikko

poojash

3 years 5 months ago

Yes i have already included

Yes i have already included it

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

I don't know what is data.h. time_toString2 is in date.h. Have you added it date.h?

BR,
Mikko

poojash

3 years 5 months ago

Yes i have added date.h file

Yes i have added date.h file

poojash

3 years 5 months ago

Hi,

Hi,
Is there any other method to get Billing date using "0,0,0,1,2,255" this OBIS code

poojash

3 years 5 months ago

Hi,

Hi,
I am using ATSAME54 board to read data from meter. I checked date.c file. There is condition
"#if !defined(GX_DLMS_MICROCONTROLLER)" to use "time_toString2() ". So please help what should i have to do.

poojash

3 years 5 months ago

Thanks for the support I got

Thanks for the support I got time in string.

poojash

3 years 5 months ago

I used strftime() function to

I used strftime() function to convert the time.

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

I'm glad that you solved this.
I was thinking this and it might be good if time_toString2 is available even GX_DLMS_MICROCONTROLLER is defined. It might be handy in some cases.
It will be available in the next version.

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Fri, 05/09/2025 - 13:03
    Gurux.DLMS.Python 1.0.181
  • Wed, 05/07/2025 - 16:09
    Gurux.DLMS.Android 2.0.14
  • Tue, 05/06/2025 - 09:34
    gurux.dlms.c 9.0.2505.0601
  • Tue, 05/06/2025 - 08:51
    GXDLMSDirector 9.0.2505.0601
  • Tue, 05/06/2025 - 08:26
    gurux.dlms.java 4.0.79

New forum topics

  • I LOST MY CRYPTO, HOW DO I RECOVER IT? iFORCE HACKER RECOVERY
  • GXNet python implementation hangs on close
  • Conexión Landis ZMG310 Protocolo IEC
  • I need function of below OBIS code
  • How communicating with meter using proparatory command
More

Who's new

  • John Willis
  • nnn
  • raghavrg09
  • Haithem_boubaker
  • sobatih
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin