diff options
author | Stefan Adolfsson <sadolfsson@google.com> | 2018-04-24 12:13:46 +0200 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-06-19 19:58:38 +0000 |
commit | 387ddfa1707981d07d76ee38ff8dcee75b99b669 (patch) | |
tree | 4f5987b4097d8c47b4d12439196c195da35e70bf | |
parent | 52d50d30d9711921d9f7162882b23c6422e2b238 (diff) | |
download | chrome-ec-387ddfa1707981d07d76ee38ff8dcee75b99b669.tar.gz |
CEC: Wait for send-event after cec writes in ectool
For factory testing purposes, make the cecwrite
return-value depend on whether it got an ACK from the sink.
Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>
BUG=b:76467407
BRANCH=none
TEST=Using EC firmware with CEC support, ectool cecwrite with
and without sink
CQ-DEPEND=CL:1030215
Reviewed-on: https://chromium-review.googlesource.com/1030216
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I681243f74e4745796ac8d50e60dc0f7f9c087335
Reviewed-on: https://chromium-review.googlesource.com/1055515
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Commit-Queue: Stefan Adolfsson <sadolfsson@chromium.org>
-rw-r--r-- | util/ectool.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/util/ectool.c b/util/ectool.c index 19250ce008..4c45920b4e 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -7681,8 +7681,9 @@ int cmd_cec_write(int argc, char *argv[]) { char *e; long val; - int i, msg_len; + int rv, i, msg_len; struct ec_params_cec_write p; + struct ec_response_get_next_event buffer; if (argc < 2 || argc > 17) { fprintf(stderr, "%s <MSG[0]> [MSG[1] ... MSG[15]]>\n", argv[0]); @@ -7704,7 +7705,31 @@ int cmd_cec_write(int argc, char *argv[]) printf("0x%02x ", p.msg[i]); printf("\n"); - return ec_command(EC_CMD_CEC_WRITE_MSG, 0, &p, msg_len, NULL, 0); + rv = ec_command(EC_CMD_CEC_WRITE_MSG, 0, &p, msg_len, NULL, 0); + if (rv < 0) + return rv; + + rv = ec_pollevent(1 << EC_MKBP_EVENT_CEC, &buffer, + sizeof(buffer), 1000); + if (rv == 0) { + fprintf(stderr, "Timeout waiting CEC event\n"); + return -ETIMEDOUT; + } else if (rv < 0) { + perror("Error polling for MKBP event\n"); + return -EIO; + } + + if (buffer.data.cec_events & EC_MKBP_CEC_SEND_OK) + return 0; + + if (buffer.data.cec_events & EC_MKBP_CEC_SEND_FAILED) { + fprintf(stderr, "Send failed\n"); + return -1; + } + + fprintf(stderr, "No send result received\n"); + + return -1; } /* NULL-terminated list of commands */ |