summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-03-21 17:42:52 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-03-27 18:45:01 +0000
commit3f3a2e20a1c24982bf71ec31653f7321c1017439 (patch)
treee60772a37e6d549f7526fe6eebb532a008411eb8
parent242f1957714153075e2eb9d5541923d28f05ec7c (diff)
downloadchrome-ec-3f3a2e20a1c24982bf71ec31653f7321c1017439.tar.gz
Add a few more error messages to the EC console
This adds explanations for all the error codes in enum ec_error_list, so that console commands that fail can print the reason. BUG=none BRANCH=ToT TEST=none I can't find any console commands that return errors without explanations, but I'm planning to add some. This is just preparation. Change-Id: I26a730acb60a73c269c39ae2f24273b7e9920cec Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191781 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/console.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/common/console.c b/common/console.c
index f310ef41a7..2920db60fc 100644
--- a/common/console.c
+++ b/common/console.c
@@ -136,6 +136,20 @@ static const struct console_command *find_command(char *name)
return match;
}
+
+static const char const *errmsgs[] = {
+ "OK",
+ "Unknown error",
+ "Unimplemented",
+ "Overflow",
+ "Timeout",
+ "Invalid argument",
+ "Busy",
+ "Access Denied",
+ "Not Powered",
+ "Not Calibrated",
+};
+
/**
* Handle a line of input containing a single command.
*
@@ -168,16 +182,14 @@ static int handle_command(char *input)
return rv;
/* Print more info for errors */
- if (rv == EC_ERROR_INVAL)
- ccputs("Command usage/param invalid.\n");
+ if (rv < ARRAY_SIZE(errmsgs))
+ ccprintf("%s\n", errmsgs[rv]);
+ else if (rv >= EC_ERROR_PARAM1 && rv < EC_ERROR_PARAM_COUNT)
+ ccprintf("Parameter %d invalid\n", rv - EC_ERROR_PARAM1 + 1);
else if (rv == EC_ERROR_PARAM_COUNT)
- ccputs("Wrong number of params.\n");
- else if (rv >= EC_ERROR_PARAM1 && rv <= EC_ERROR_PARAM9)
- ccprintf("Parameter %d invalid.\n", rv - EC_ERROR_PARAM1 + 1);
- else if (rv != EC_SUCCESS) {
+ ccputs("Wrong number of params\n");
+ else if (rv != EC_SUCCESS)
ccprintf("Command returned error %d\n", rv);
- return rv;
- }
#ifdef CONFIG_CONSOLE_CMDHELP
if (cmd->argdesc)