Commit 06cb0670 authored by Alessandro Rubini's avatar Alessandro Rubini

time-wrs: implement time_set()

The non-wr servo calls time_set when the offset is more than 1second.
However, we can't set the time, but we can force a big adjustment.

So this code now adjusts the WR seconds, to reach a less-than-one-second
error, to let the servo rthen converge with small adjustments.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ec537cd1
......@@ -197,11 +197,22 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
static int32_t wrs_time_set(struct pp_instance *ppi, TimeInternal *t)
{
/* FIXME Don't know how to implement this. Actually it's almost unused
* in ppsi, only proto-standard/servo.c calls it, at initialization
* time */
pp_diag(ppi, time, 1, "%s: (not supported) %9li.%09li\n", __func__,
int64_t offset_sec;
/*
* This is almost unused in ppsi, only proto-standard/servo.c
* calls it, at initialization time, when the offset is bigger
* than one second. Run this transient by just adjusting the
* WR seconds. Later on it will fix the nanos by ->adjust
*/
pp_diag(ppi, time, 1, "%s: (weird) %9li.%09li\n", __func__,
(long)t->seconds, (long)t->nanoseconds);
/* We have no way to get the WR time, currently. So use our T3 */
offset_sec = (long long)t->seconds - (long long)ppi->t3.seconds;
pp_diag(ppi, time, 1, "%s: adjusting seconds: %li\n", __func__,
(long)offset_sec);
wrs_adjust_counters(offset_sec, 0);
/* Set unix time anyways */
unix_time_ops.set(ppi, t);
return -ENOTSUP;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment