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

RTC update

Profile picture for user batulzii
By batulzii , 4 January, 2024
Forums
Gurux.DLMS

DLMS Server has RTC chip for clock object. what is best way to adopt RTC chip update in the Gurux DLMS stack?

Profile picture for user Kurumi

Kurumi

2 years 5 months ago

Hi, I believe that you are…

Hi,

I believe that you are making a meter and we are talking from the server side.

Handle write in pre_write and update clock like this.

if (e->target == BASE(clock1) && e->index == 2)
{
gxtime value;
if (cosem_getDateTimeFromOctetString(e->value.byteArr, &value) == 0)
{
//Update RTC.
time_toUTC(value);
}
}

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 5 months ago

using pcf85263a RTC chip…

using pcf85263a RTC chip. and i'd like track clock object by this chip. server samples has clock1 object. do you have guide for this type adoption? for reading i'd made changes like:
uint32_t time_current(void)
{
struct rtc_time tmUtc;
//return time_toUnixTime2(&clock1.time) + (time_elapsed() - started) / 1000;
rtc_get_time(rtcMeter, &tmUtc);
return decode_rtc(tmUtc);

}
and for setting, not sure about changes

Profile picture for user Kurumi

Kurumi

2 years 5 months ago

Hi, Are you using VS Code or…

Hi,

Are you using VS Code or Arduino?

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 5 months ago

VSC. Nordic server

Hi,
VSC. Nordic server.
Thanks for kind support!

Profile picture for user batulzii

batulzii

2 years 5 months ago

Hello, I can update RTC…

Hello,
I can update RTC chip in pre_write as you've advised. but how make changes on cosem_setValue( ... which is called in origin code. it managed clock & date logic too.
BR,
Ulzii

Profile picture for user Kurumi

Kurumi

2 years 5 months ago

Hi, You don't need to update…

Hi,

You don't need to update the date time if you are using RTC. It's better to read value from RTC in pre_read and use that value. Something like this:

if (e->target == BASE(clock1) && e->index == 2)
{
gxtime dt;
time_now(&dt, 1);
e->error = (DLMS_ERROR_CODE) cosem_setDateTimeAsOctetString(e->value.byteArr, &dt);
e->value.vt = DLMS_DATA_TYPE_DATETIME;
e->handled = 1;
}

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 5 months ago

Hi, Our meter HES will need…

Hi,
Our meter HES will need update datetime at least for deploy etc, so i need to write for update our RTC chip's datetime.
BR,
Ulzii

Profile picture for user Kurumi

Kurumi

2 years 5 months ago

Hi, My bad. :-) What I meant…

Hi,

My bad. :-)
What I meant is that you don't need to call cosem_setValue for time if you read it on pre-read from RTC. You can, but there is no need for that.

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 5 months ago

Hi, I'd like to set server…

Hi,
I'd like to set server time to new time (click on "current time" button.), then i'd like to call settime() function - setting new time on rtc. And Clock object has many feature like DTS or Time zone... I do not know best possible adopt to origin code with RTC chip conversation.
BR,
Ulzii

Profile picture for user Kurumi

Kurumi

2 years 5 months ago

Hi, You can do it in pre…

Hi,

You can do it in pre_write like described here:

https://www.gurux.fi/comment/27237#comment-27237

When you have time in UTC you can update it using a method like rtc_set_time.

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
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin