diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2016-10-02 10:47:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-05 04:03:19 -0700 |
commit | e40fb3ef58a47d13418b2b6665026cf2ae5fd51e (patch) | |
tree | 01e45f73abd0bdac8b5d2cc62112598b96007017 /util | |
parent | 701223cf0950dccb0e10f3e7b4eb419224d1f21a (diff) | |
download | chrome-ec-e40fb3ef58a47d13418b2b6665026cf2ae5fd51e.tar.gz |
util: Fix fifo_info when lost vectors are present
Due to an error in ms_command_sizes, fifo_info command
would fail when lost vectors are present:
packet too long (16 bytes, expected 10)
Reorder ms_command_sizes commands properly.
Get the number of sensors present before printing the number of lost
vectors per sensor.
BUG=none
BRANCH=none
TEST=On cave (with broken MKBP support), check fifo_info
is returning the lost vectors count.
Change-Id: Ic745eb762563705372d8a670ce34eab15e188bf9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391887
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/util/ectool.c b/util/ectool.c index ac9357dda0..2b7e5f2bf4 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -3425,8 +3425,8 @@ static const struct { MS_SIZES(sensor_range), MS_SIZES(kb_wake_angle), MS_SIZES(data), - MS_SIZES(fifo_flush), MS_FIFO_INFO_SIZE(), + MS_SIZES(fifo_flush), MS_SIZES(fifo_read), MS_SIZES(perform_calib), MS_SIZES(sensor_offset), @@ -3452,7 +3452,7 @@ static int ms_help(const char *cmd) printf(" %s data NUM - read sensor latest data\n", cmd); printf(" %s fifo_info - print fifo info\n", cmd); - printf(" %s fifo_int enable [0/1] - enable/disable/get fifo " + printf(" %s fifo_int_enable [0/1] - enable/disable/get fifo " "interrupt status\n", cmd); printf(" %s fifo_read MAX_DATA - read fifo data\n", cmd); printf(" %s fifo_flush NUM - trigger fifo interrupt\n", @@ -3742,6 +3742,17 @@ static int cmd_motionsense(int argc, char **argv) } if (argc == 2 && !strcasecmp(argv[1], "fifo_info")) { + int sensor_count; + + param.cmd = MOTIONSENSE_CMD_DUMP; + param.dump.max_sensor_count = 0; + rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 1, + ¶m, ms_command_sizes[param.cmd].outsize, + resp, ms_command_sizes[param.cmd].insize); + if (rv < 0) + return rv; + sensor_count = resp->dump.sensor_count; + param.cmd = MOTIONSENSE_CMD_FIFO_INFO; rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 2, ¶m, ms_command_sizes[param.cmd].outsize, @@ -3753,7 +3764,7 @@ static int cmd_motionsense(int argc, char **argv) printf("Count: %d\n", resp->fifo_info.count); printf("Timestamp:%" PRIx32 "\n", resp->fifo_info.timestamp); printf("Total lost: %d\n", resp->fifo_info.total_lost); - for (i = 0; i < ECTOOL_MAX_SENSOR; i++) { + for (i = 0; i < sensor_count; i++) { int lost; lost = resp->fifo_info.lost[i]; if (lost != 0) |