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;
}
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));
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.
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.
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
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));
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
hi,
hi,
Now getting "undefined reference to `time_toString2'" this error. since I included data.h file
Hi,
Hi,
You need to also add data.c -file.
BR,
Mikko
I dont have data.c file'
I dont have data.c file'
Sorry,
Sorry,
You need to also add date.c -file.
BR,
Mikko
Yes i have already included
Yes i have already included it
Hi,
Hi,
I don't know what is data.h. time_toString2 is in date.h. Have you added it date.h?
BR,
Mikko
Yes i have added date.h file
Yes i have added date.h file
Hi,
Hi,
Is there any other method to get Billing date using "0,0,0,1,2,255" this OBIS code
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.
Thanks for the support I got
Thanks for the support I got time in string.
I used strftime() function to
I used strftime() function to convert the time.
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