Commit a9114d22 authored by Alessandro Rubini's avatar Alessandro Rubini

stat: only print statistics when something happened

This change monitors the update_count of wr_servo, and only prints
a statistics line when something happens.

This means we won't have long "TRACK_PHASE" listings when the master
is dead. Moreover, we see changes when they happen, not at a random
time during the next second.

The bad side of the thing is that if nothing happens in the wr servo,
nothing is ever printed. But see next commit.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent 67c9e10f
......@@ -268,20 +268,18 @@ static void wrc_mon_std_servo(void)
int wrc_log_stats(void)
static uint32_t last;
static uint32_t last = ~0; /* if we are master, update count is 0 */
struct hal_port_state state;
int tx, rx;
int aux_stat;
uint64_t sec;
uint32_t nsec;
if (!last)
last = timer_get_tics() - 1 - wrc_ui_refperiod;
if (time_before(timer_get_tics(), wrc_ui_refperiod + last))
return 0;
struct wr_servo_state *s =
&((struct wr_data *)ppi->ext_data)->servo_state;
last = timer_get_tics();
if (last == s->update_count)
return 0;
last = s->update_count;
shw_pps_gen_get_time(&sec, &nsec);
wrpc_get_port_state(&state, NULL);
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