This is the mail archive of the
mailing list for the eCos project.
Re: Absolute vs. relative tick count.
"Rene Nielsen" <email@example.com> writes:
> I'd really like to have two counters in the Cyg_RealTimeClock (or one of
> its parent classes): One that can be changed with a call to
> clock_settime()/Cyg_Clock::real_time_clock->set_value() and one that
> counts the number of ticks since boot and can't be changed. There should
> also be two sets of functions for obtaining these values depending on
> whether they're going to be used in e.g. gettimeofday() or for
> Any suggestions/ideas would be very helpful.
Here's what I did:
* Added Cyg_WallClock::get_hw_usecs to the emulated wallclock driver:
returns the number of µs elapsed since initialisation.
* Added Cyg_WallClock::adjtime to the wallclock base driver: takes a
positive/negative offset [µs] as argument and updates an internally
kept variable "adj_delta".
* Added Cyg_WallClock::get_current_time_us to the wallclock base
driver: returns the number of µs elapsed since 1970-01-01T00:00,
offset by "adj_delta" and implemented in terms of
* Changed gettimeofday to use Cyg_WallClock::get_current_time_us.
* In the (S)NTP client use gettimeofday to calculate the time
difference and, if needed, adjust the clock with
Cyg_WallClock::adjtime (I use my own SNTP implementation though).
I hope that helps, and if the maintainers are interested I could maybe
clean this up a bit and submit a patch.
Daniel Néri <firstname.lastname@example.org>
Sigicom AB, Stockholm, Sweden
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss