summaryrefslogtreecommitdiff
path: root/common/charge_state_v2.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-05-14 12:13:08 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-15 05:28:08 +0000
commit65df2fd6e444f6655838d55af63de59e699238a2 (patch)
tree8049186891b2509a1bced4d30cf4ba15b238d54c /common/charge_state_v2.c
parent10aecec841361727e7ed8f16a13e0d7a575e77ff (diff)
downloadchrome-ec-65df2fd6e444f6655838d55af63de59e699238a2.tar.gz
Add "debug" option to charge_state_v2.c
This is useful for testing battery charge profiles. When enabled, a dump of all battery, charger, and charge state information will be printed whenever the battery charge percentage changes. BUG=none BRANCH=ToT TEST=make buildall -j On the EC console: chg debug on then watch the console while either charging or discharging the battery. Disable with chg debug off Change-Id: I6725c461461f90fcd812873f97490e980ab47bc6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/199816 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r--common/charge_state_v2.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index a5a621da8b..3109f23363 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -43,6 +43,7 @@ test_export_static timestamp_t shutdown_warning_time;
static timestamp_t precharge_start_time;
static int battery_seems_to_be_dead;
static int problems_exist;
+static int debugging;
/* Track problems in communicating with the battery or charger */
enum problem_type {
@@ -245,6 +246,7 @@ static void dump_charge_state(void)
ccprintf(" manual_mode = %d\n", manual_mode);
ccprintf(" user_current_limit = %dmA\n", user_current_limit);
ccprintf(" battery_seems_to_be_dead = %d\n", battery_seems_to_be_dead);
+ ccprintf(" debug output = %s\n", debugging ? "on" : "off");
#undef DUMP
}
@@ -270,6 +272,15 @@ static void show_charging_progress(void)
curr.batt.state_of_charge,
minutes / 60, minutes % 60,
to_full ? "to full" : "to empty");
+
+ if (debugging) {
+ ccprintf("battery:\n");
+ print_battery_debug();
+ ccprintf("charger:\n");
+ print_charger_debug();
+ ccprintf("chg:\n");
+ dump_charge_state();
+ }
}
/*
@@ -917,6 +928,11 @@ static int command_chgstate(int argc, char **argv)
rv = charge_force_idle(val);
if (rv)
return rv;
+ } else if (!strcasecmp(argv[1], "debug")) {
+ if (argc <= 2)
+ return EC_ERROR_PARAM_COUNT;
+ if (!parse_bool(argv[2], &debugging))
+ return EC_ERROR_PARAM2;
} else {
/* maybe handle board_discharge_on_ac() too? */
return EC_ERROR_PARAM1;
@@ -927,6 +943,6 @@ static int command_chgstate(int argc, char **argv)
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(chgstate, command_chgstate,
- "[idle on|off]",
+ "[idle|debug on|off]",
"Get/set charge state machine status",
NULL);