hello,
I"m trying to finish up this Open issue
and i’m struggling with this ticket right now.
this ticket is to change the current implementation of rtems_clock_get_tod: to use Gmtime as opposed to the current one that uses it’s own math and to allow years beyond 2100. I think I was able to get the implementation down but i am not sure if my testing verifies it correctly. that being said i also doubt what what i’ve written for rtems_clock_get_tod
_TOD_Get_timeval( &now );
current_time_tm = gmtime_r( &now.tv_sec, &buf );
_Assert( current_time_tm != NULL );
time_of_day->year = 1900 + current_time_tm->tm_year;
time_of_day->month = 1 + current_time_tm->tm_mon;
time_of_day->day = current_time_tm->tm_mday;
time_of_day->hour = current_time_tm->tm_hour;
time_of_day->minute = current_time_tm->tm_min;
time_of_day->second = current_time_tm->tm_sec;
time_of_day->ticks = now.tv_usec /
rtems_configuration_get_microseconds_per_tick( );
this is my current implimentation rtems get clock_tod which calls gmtime_r and returns and populates the struct.
my current way i’m testing is to do this
rtems_status_code status;
rtems_time_of_day new_tod;
status = rtems_clock_set( the_tod );
rtems_test_assert( !status );
status = rtems_clock_get_tod( &new_tod );
rtems_test_assert( !status );
rtems_test_assert( new_tod.year == the_tod->year );
rtems_test_assert( new_tod.month == the_tod->month);
rtems_test_assert( new_tod.day == the_tod->day );
rtems_test_assert( new_tod.hour == the_tod->hour);
rtems_test_assert( new_tod.minute == the_tod->minute );
rtems_test_assert( new_tod.second == the_tod->second);
rtems_test_assert( new_tod.ticks == the_tod->ticks );
currently i use the_tod as a passed in argument and it use rtems_clock_set to set that to the time. And then i use clock_get_tod to get the tod and compare the fields it seems to fail when i choose times above 2100 and i’ve tested with with years <2100.
I"m right now trying to write a test in linux first .
time_t now= 1745701522;
struct tm buf;
struct tm *current_time_tm;
current_time_tm = gmtime_r( &now, &buf );
time_t myTime_t = mktime(current_time_tm);
printf("The current local time is: %ld", myTime_t -now);
using time_t to set time (i use a epoch converter) then i pass it into gmtime_r then i use mktime to convert it and compare it with now
Am i on the right track what suggestion do you have?
thanks!