mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
10aecec841
commit
65df2fd6e4
@@ -209,6 +209,14 @@ static void print_battery_info(void)
|
||||
}
|
||||
}
|
||||
|
||||
void print_battery_debug(void)
|
||||
{
|
||||
print_battery_status();
|
||||
print_battery_params();
|
||||
print_battery_strings();
|
||||
print_battery_info();
|
||||
}
|
||||
|
||||
static int command_battery(int argc, char **argv)
|
||||
{
|
||||
int repeat = 1;
|
||||
@@ -233,10 +241,7 @@ static int command_battery(int argc, char **argv)
|
||||
}
|
||||
|
||||
for (loop = 0; loop < repeat; loop++) {
|
||||
print_battery_status();
|
||||
print_battery_params();
|
||||
print_battery_strings();
|
||||
print_battery_info();
|
||||
print_battery_debug();
|
||||
|
||||
/*
|
||||
* Running with a high repeat count will take so long the
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Common functions for battery charging.
|
||||
*/
|
||||
|
||||
#include "battery_smart.h"
|
||||
#include "charger.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
@@ -114,7 +115,7 @@ static int check_print_error(int rv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_info(void)
|
||||
void print_charger_debug(void)
|
||||
{
|
||||
int d;
|
||||
const struct charger_info *info = charger_get_info();
|
||||
@@ -165,8 +166,6 @@ static int print_info(void)
|
||||
ccprintf("%5d\n", dptf_limit_ma);
|
||||
else
|
||||
ccputs("disabled\n");
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int command_charger(int argc, char **argv)
|
||||
@@ -174,8 +173,10 @@ static int command_charger(int argc, char **argv)
|
||||
int d;
|
||||
char *e;
|
||||
|
||||
if (argc != 3)
|
||||
return print_info();
|
||||
if (argc != 3) {
|
||||
print_charger_debug();
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "input") == 0) {
|
||||
d = strtoi(argv[2], &e, 0);
|
||||
|
||||
@@ -309,4 +309,9 @@ int battery_set_vendor_param(uint32_t param, uint32_t value);
|
||||
*/
|
||||
int battery_wait_for_stable(void);
|
||||
|
||||
/**
|
||||
* Print all battery info for debugging purposes
|
||||
*/
|
||||
void print_battery_debug(void);
|
||||
|
||||
#endif /* __CROS_EC_BATTERY_H */
|
||||
|
||||
@@ -107,5 +107,8 @@ int charger_device_id(int *id);
|
||||
int charger_get_option(int *option);
|
||||
int charger_set_option(int option);
|
||||
|
||||
/* Print all charger info for debugging purposes */
|
||||
void print_charger_debug(void);
|
||||
|
||||
#endif /* __CROS_EC_CHARGER_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user