diff --git a/common/smart_battery.c b/common/smart_battery.c index 536959bd82..3991a2e270 100644 --- a/common/smart_battery.c +++ b/common/smart_battery.c @@ -229,6 +229,7 @@ static int command_battery(int argc, char **argv) int repeat = 1; int rv = 0; int loop; + int sleep_ms = 0; char *e; if (argc > 1) { @@ -239,16 +240,31 @@ static int command_battery(int argc, char **argv) } } - for (loop = 0; loop < repeat; loop++) + if (argc > 2) { + sleep_ms = strtoi(argv[2], &e, 0); + if (*e) { + ccputs("Invalid sleep ms\n"); + return EC_ERROR_INVAL; + } + } + + for (loop = 0; loop < repeat; loop++) { rv = print_battery_info(); + if (sleep_ms) + msleep(sleep_ms); + + if (rv) + break; + } + if (rv) ccprintf("Failed - error %d\n", rv); return rv ? EC_ERROR_UNKNOWN : EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(battery, command_battery, - "", + " ", "Print battery info", NULL);