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. Date-time Conversion Issue Around Com_readRowsByRange and Time_init3

date-time conversion issue around com_readRowsByRange and time_init3

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 Vishal Patel , 18 February, 2021
Forums
General discussion

Hi Mikko,

I'm using Gurux DLMS C Library.

-> I'm facing issue in date-time conversion around com_readRowsByRange. I'm using below snippet:

year = 2021; month = 2; day = 17; hour = 6; min = 0; sec = 0; msec = 0;
time_init3(&pgSelector_info.time_pGFrom, year, month, day, hour, min, sec, msec);

year = 2021; month = 2; day = 17; hour = 8; min = 0; sec = 0; msec = 0;
time_init3(&pgSelector_info.time_pGTo, year, month, day, hour, min, sec, msec);

com_readRowsByRange(connection, obj, &pgSelector_info.time_pGFrom.value, &pgSelector_info.time_pGTo.value);

-> devitation conversion after time_getUtcOffset() API is: -330 (devitation = -(hours * 60 + minutes);)

-> The generated request for PG index 2 is:

1: 00 01 00 20 00 01 00 53 C8 51 30 00 00 00 02 EE 65 F5 C1 A6 99 49 99 51 FA B4 B5 A4 DB 70 94 9F 6E 9F E7 75 4A 22 FF 31 2F 4F 30 2D 4F B8 80 91 DD 59 6B 67 B2 F9 93 44 BD 38 D2 1E 62 D3 8E 2B BF DD CD 9A 1F 53 2F 97 B4 1B 0F DA C0 C7 4F AC BF 9E C0 BF 33 30 FB 91 F4 C5 96
<WRAPPER len="5B" >
<TargetAddress Value="20" />
<SourceAddress Value="1" />
<PDU>
<!-- Invocation Counter: 2 -->
<!-- Decrypt data: C0 01 81 00 07 01 00 63 01 00 FF 02 01 01 02 04 02 04 12 00 08 09 06 00 00 01 00 00 FF 0F 02 12 00 00 09 0C 07 E5 02 11 03 00 1E 00 00 00 00 00 09 0C 07 E5 02 11 03 02 1E 00 00 00 00 00 01 00
<GetRequest>
<GetRequestNormal>
# Priority: High, ServiceClass: UnConfirmed, ID: 1
<InvokeIdAndPriority Value="81" />
<AttributeDescriptor>
# ProfileGeneric
<ClassId Value="0007" />
# 1.0.99.1.0.255
<InstanceId Value="0100630100FF" />
<AttributeId Value="02" />
</AttributeDescriptor>
<AccessSelection>
<AccessSelector Value="01" />
<AccessParameters>
<Structure Qty="04" >
<Structure Qty="04" >
<UInt16 Value="0008" />
# 0.0.1.0.0.255
<OctetString Value="0000010000FF" />
<Int8 Value="02" />
<UInt16 Value="0000" />
</Structure>
# 17-02-2021 00:30:00Z
<OctetString Value="07E5021103001E0000000000" />
# 17-02-2021 02:30:00Z
<OctetString Value="07E5021103021E0000000000" />
<Array Qty="00" >
</Array>
</Structure>
</AccessParameters>
</AccessSelection>
</GetRequestNormal>
</GetRequest>
-->
<glo_GetRequest Value="3000000002EE65F5C1A699499951FAB4B5A4DB70949F6E9FE7754A22FF312F4F302D4FB88091DD596B67B2F99344BD38D21E62D38E2BBFDDCD9A1F532F97B41B0FDAC0C74FACBF9EC0BF3330FB91F4C596" />
</PDU>
</WRAPPER>

here, time converting 5.30hr less in request itself. (0.30 instead of 6.00 and 2.30 instead of 8.00)

can you help me with this ?

Regards,
Vishal

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi,

Hi,

I believe that you haven't defined DLMS_USE_UTC_TIME_ZONE.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSClock

BR,
Mikko

Vishal Patel

5 years 3 months ago

I did enable DLMS_USE_UTC

I did enable DLMS_USE_UTC_TIME_ZONE macro in gxignore.h header file. but still same result. no change.

Vishal Patel

5 years 3 months ago

Hi Mikko,

Hi Mikko,

same as last comment, I did enable DLMS_USE_UTC_TIME_ZONE macro in gxignore.h header file. but still facing same issue, cannot see any positive result.

Can you plz check once and let me know how can I fix this issue?

Regards,
Vishal

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi,

Hi,

This is now checked and it seems to work as expected. I was checking your code and I notest that the deviation is not -330, it's 0. Reason for this is that you are using com_readRowsByRange. Use com_readRowsByRange2 and you can set the deviation. There is no deviation in struct tm.

Something like this:

Change time_pGFrom from struct tm to gxtime.

time_init3(&pgSelector_info.time_pGFrom, year, month, day, hour, min, sec, msec);
pgSelector_info.time_pGFrom.deviation = 330;

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

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin