diff options
author | Doug Anderson <dianders@chromium.org> | 2013-08-27 09:54:47 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-08-27 23:30:01 +0000 |
commit | 703ce2abf2e38b0f1434224534c1be505e1244f7 (patch) | |
tree | 07df0d8f2f6f6c2e082ec58e3435330ab0244acc | |
parent | deab2433c13bc3b3bb75cd33c12dad633ba6a42a (diff) | |
download | chrome-ec-703ce2abf2e38b0f1434224534c1be505e1244f7.tar.gz |
battery: Add sleep param; make errors fatal in the loop
If you're running the battery command in a loop:
* You may need a sleep so you don't trigger watchdog resets, at least
if you're running at a low clock frequency.
* You probably want to break on an error.
Make the sleep delay come from a parameter since you might want to
avoid it if you just want to pound on the bus as fast as possible.
BRANCH=pit
BUG=chrome-os-partner:22093
TEST=With all patches together:
- on AP: suspend_stress_test
- on EC: battery 10000 50
Change-Id: I6ae6d818c06f59064e90bd6d23d6d4c782544849
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167103
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/smart_battery.c | 20 |
1 files changed, 18 insertions, 2 deletions
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, - "<repeat_count>", + "<repeat_count> <sleep_ms>", "Print battery info", NULL); |