summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Srivastava <shobhit.srivastava@intel.com>2021-12-03 19:09:56 +0530
committerCommit Bot <commit-bot@chromium.org>2021-12-07 18:28:22 +0000
commit448e1a573b70a5f4db5c780448aa00eec55559eb (patch)
tree254adc8a66903e3cf9cf67bbd649b05a653c8e48
parent90f4554e942dd3831470426cfe9ef59846afebfa (diff)
downloadchrome-ec-448e1a573b70a5f4db5c780448aa00eec55559eb.tar.gz
ectool: Fix ec_rate command invocation
The ec_rate host command expects the sensor number to be passed as an argument. However the ectool was not sending that value BUG=b:208966957 TEST=ectool motionsense ec_rate <sensor num> displays ec rate Signed-off-by: Shobhit Srivastava <shobhit.srivastava@intel.com> Change-Id: I30c3ebadf245c209c1d471e9ddc24fa111a51b05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3314491 Reviewed-by: Boris Mittelberg <bmbm@google.com> Commit-Queue: YH Lin <yueherngl@chromium.org>
-rw-r--r--util/ectool.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 4da67aae52..3eaac876fd 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -5098,7 +5098,7 @@ static int ms_help(const char *cmd)
cmd);
printf(" %s active - print active flag\n", cmd);
printf(" %s info NUM - print sensor info\n", cmd);
- printf(" %s ec_rate [RATE_MS] - set/get sample rate\n",
+ printf(" %s ec_rate NUM [RATE_MS] - set/get sample rate\n",
cmd);
printf(" %s odr NUM [ODR [ROUNDUP]] - set/get sensor ODR\n",
cmd);
@@ -5167,7 +5167,6 @@ static int cmd_motionsense(int argc, char **argv)
{ "Motion sensing inactive", "0"},
{ "Motion sensing active", "1"},
};
-
/* No motionsense command has more than 7 args. */
if (argc > 7)
return ms_help(argv[0]);
@@ -5389,14 +5388,18 @@ static int cmd_motionsense(int argc, char **argv)
return 0;
}
- if (argc < 4 && !strcasecmp(argv[1], "ec_rate")) {
+ if (argc > 2 && !strcasecmp(argv[1], "ec_rate")) {
param.cmd = MOTIONSENSE_CMD_EC_RATE;
param.ec_rate.data = EC_MOTION_SENSE_NO_VALUE;
-
- if (argc == 3) {
- param.ec_rate.data = strtol(argv[2], &e, 0);
+ param.sensor_odr.sensor_num = strtol(argv[2], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad %s arg.\n", argv[2]);
+ return -1;
+ }
+ if (argc == 4) {
+ param.ec_rate.data = strtol(argv[3], &e, 0);
if (e && *e) {
- fprintf(stderr, "Bad %s arg.\n", argv[2]);
+ fprintf(stderr, "Bad %s arg.\n", argv[3]);
return -1;
}
}