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 5 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 5 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 5 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 5 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

  • 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

  • mPDxPIQgXwPXoV…
  • AaronAcecy
  • lin
  • JFaHTYnuOHYICbRfEZ
  • ukTdwoUGQDQQrJ…
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin