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

  • 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

  • Version mismatch between Gurux.DLMS 9.x and Gurux.Common/Gurux.Serial 8.x
  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
More

Who's new

  • ArthurDaype
  • hirenec11mic
  • Yeyen
  • Virtual
  • joesa4
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin