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

  • 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