cmd_stat.c 854 Bytes
Newer Older
1
#include "shell.h"
2
#include "endpoint.h"
3 4
#include <string.h>
#include <wrc.h>
5 6 7
#include <errno.h>

int wrc_stat_running;
8
extern uint32_t wrc_stats_last;
9

10
static int cmd_stat(const char *args[])
11
{
12 13 14
	/* no arguments: invert */
	if (!args[0]) {
		wrc_stat_running = !wrc_stat_running;
15
		wrc_stats_last--; /* force a line to be printed */
16 17
		if (!wrc_stat_running)
			pp_printf("statistics now off\n");
18 19 20 21
		return 0;
	}

	/* arguments: bts, on, off */
22
	if (!strcasecmp(args[0], "bts")) {
23
		pp_printf("%d ps\n", ep_get_bitslide());
24
	} else if (!strcasecmp(args[0], "on")) {
25
		wrc_stat_running = 1;
26 27
		wrc_stats_last--; /* force a line to be printed */
	} else if (!strcasecmp(args[0], "off")) {
28
		wrc_stat_running = 0;
29 30
		pp_printf("statistics now off\n");
	} else
31
		return -EINVAL;
32
	return 0;
33

34
}
35 36 37 38 39

DEFINE_WRC_COMMAND(stat) = {
	.name = "stat",
	.exec = cmd_stat,
};