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. Node
  3. Pass Start Time & End Time As String

Pass Start Time & End Time as string

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 Techapirant , 8 November, 2019
Forums
Gurux.DLMS

Hello,

While reading data of profile generic using below command how can i pass start time and end time as string ?
com_readRowsByRange(&con, pg, &startTime.value, &endTime.value);

Profile picture for user Kurumi

Kurumi

6 years 10 months ago

Hi,

Hi,

You must convert string to struct tm. This depends on the operating system and compiler, etc..

BR,

Mikko

Techapirant

6 years 10 months ago

Hello,

Hello,

I am using gcc compiler and Linux Ubuntu 64 Bit OS
Below is my code I am using but getting error
/* Start Time */
char *global_starttime = "2008-12-10 10:00:00";
struct tm *parsedTime;
int year, month, day, hour, minute, second;
if(sscanf(global_starttime, "%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second) != EOF){
time_t rawTime;
time(&rawTime);
parsedTime = localtime(&rawTime);
parsedTime->tm_year = year;
parsedTime->tm_mon = month;
parsedTime->tm_mday = day;
parsedTime->tm_hour = hour;
parsedTime->tm_min = minute;
parsedTime->tm_sec = second;
}

/* End Time */
char *global_endtime = "2008-12-11 10:00:00";
struct tm *parsedTime_endtime;
if(sscanf(global_endtime, "%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second) != EOF){
time_t rawTime;
time(&rawTime);
parsedTime_endtime = localtime(&rawTime);
parsedTime_endtime->tm_year = year;
parsedTime_endtime->tm_mon = month;
parsedTime_endtime->tm_mday = day;
parsedTime_endtime->tm_hour = hour;
parsedTime_endtime->tm_min = minute;
parsedTime_endtime->tm_sec = second;
}

time_init2(&startTime,&parsedTime);
time_init2(&endTime,&parsedTime_endtime);

Error : time_init Assertion 0 failed

Profile picture for user Kurumi

Kurumi

6 years 10 months ago

Hi,

Hi,

Change this:
struct tm *parsedTime;
to:
struct tm parsedTime;

and try again.

BR,

Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More

Who's new

  • cyby
  • Metin Onan
  • ssv007
  • 3nzol3dur
  • dw772
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin