Commit 684fa5cd authored by Alessandro Rubini's avatar Alessandro Rubini

stat: always print one line when turning stats on

With the new "only print if sth happens" way, sometimes stats is
just silent forever. This happens if we are master or if no slave
is active (well, and during initial setting up the wr link).

So now typing "stat" or "stat on" will turn on stats and print a line
of statistics, every time -- or the line "statistics now off".
This happens by changing the internal status of monitor_ppsi.c,
now exported to the cmd_stat.c.

This is the result on a master system:

   wrc# stat
   lnk:1 rx:0 tx:3 lock:1 sv:0 ss:'' aux:1 sec:5 [...]
   wrc#
   wrc#
   wrc# stat
   statistics now off
   wrc#
   wrc#
   wrc# stat
   lnk:1 rx:0 tx:11 lock:1 sv:0 ss:'' aux:1 sec:8 [...]
   wrc#
   wrc#

And this is what happens when we become slave:

   wrc# mode slave
   Locking PLL
   wrc# ptp start
   Slave Only, clock class set to 255
   wrc# lnk:1 rx:57 tx:60 lock:1 sv:1 ss:'SYNC_SEC' aux:1 sec:49 [...]
   lnk:1 rx:70 tx:64 lock:1 sv:1 ss:'SYNC_NSEC' aux:1 sec:1444901411 [...]
   lnk:1 rx:77 tx:66 lock:1 sv:1 ss:'SYNC_PHASE' aux:1 sec:1444901414 [...]
   lnk:1 rx:83 tx:68 lock:1 sv:1 ss:'WAIT_OFFSET_STABLE' aux:1 sec:1444901416 [...]
   lnk:1 rx:87 tx:69 lock:1 sv:1 ss:'WAIT_OFFSET_STABLE' aux:1 sec:1444901417 [...]
   lnk:1 rx:90 tx:70 lock:1 sv:1 ss:'TRACK_PHASE' aux:1 sec:1444901418 [...]
   lnk:1 rx:94 tx:71 lock:1 sv:1 ss:'TRACK_PHASE' aux:1 sec:1444901419 [...]
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a9114d22
......@@ -266,9 +266,11 @@ static void wrc_mon_std_servo(void)
}
/* internal "last", exported to shell command */
uint32_t wrc_stats_last;
int wrc_log_stats(void)
{
static uint32_t last = ~0; /* if we are master, update count is 0 */
struct hal_port_state state;
int tx, rx;
int aux_stat;
......@@ -277,9 +279,9 @@ int wrc_log_stats(void)
struct wr_servo_state *s =
&((struct wr_data *)ppi->ext_data)->servo_state;
if (last == s->update_count)
if (wrc_stats_last == s->update_count)
return 0;
last = s->update_count;
wrc_stats_last = s->update_count;
shw_pps_gen_get_time(&sec, &nsec);
wrpc_get_port_state(&state, NULL);
......
......@@ -5,23 +5,26 @@
#include <errno.h>
int wrc_stat_running;
extern uint32_t wrc_stats_last;
static int cmd_stat(const char *args[])
{
/* no arguments: invert */
if (!args[0]) {
wrc_stat_running = !wrc_stat_running;
wrc_stats_last--; /* force a line to be printed */
if (!wrc_stat_running)
pp_printf("statistics now off\n");
return 0;
}
/* arguments: bts, on, off */
if (!strcasecmp(args[0], "bts"))
if (!strcasecmp(args[0], "bts")) {
mprintf("%d ps\n", ep_get_bitslide());
else if (!strcasecmp(args[0], "on"))
} else if (!strcasecmp(args[0], "on")) {
wrc_stat_running = 1;
else if (!strcasecmp(args[0], "off")) {
wrc_stats_last--; /* force a line to be printed */
} else if (!strcasecmp(args[0], "off")) {
wrc_stat_running = 0;
pp_printf("statistics now off\n");
} else
......
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