diff options
author | Allen Webb <allenwebb@google.com> | 2017-12-14 16:14:13 -0800 |
---|---|---|
committer | Allen Webb <allenwebb@google.com> | 2017-12-14 16:14:13 -0800 |
commit | 362e1673c2b2d8c4433e6a4858133434656eb744 (patch) | |
tree | 1e6c153516fa37e1d034cded99018e973cca0423 /libnos_transport | |
parent | 5eba38c1cb834e83099c22a52646671f602f6cda (diff) | |
download | generic-362e1673c2b2d8c4433e6a4858133434656eb744.tar.gz |
Retry status datagram to handle sleep / reboot.
Change-Id: If4959b2ca940fe4c6d1eb2202480afbddc033c7f
Diffstat (limited to 'libnos_transport')
-rw-r--r-- | libnos_transport/transport.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libnos_transport/transport.c b/libnos_transport/transport.c index 6ce8ef7..1e981ed 100644 --- a/libnos_transport/transport.c +++ b/libnos_transport/transport.c @@ -20,6 +20,7 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <application.h> @@ -59,7 +60,7 @@ static int get_status(const struct nos_device *dev, uint32_t command = CMD_ID(app_id) | CMD_IS_READ | CMD_TRANSPORT; if (0 != dev->ops.read(dev->ctx, command, buf, sizeof(buf))) { - NLOGE("Failed to read device status"); + NLOGV("Failed to read device status"); return -1; } @@ -91,9 +92,18 @@ uint32_t nos_call_application(const struct nos_device *dev, uint32_t status; uint16_t ulen; uint32_t poll_count = 0; + uint16_t retries = 10; /* Make sure it's idle */ - if (get_status(dev, app_id, &status, &ulen) != 0) { + while (retries) { + if (get_status(dev, app_id, &status, &ulen) == 0) { + break; + } + --retries; + usleep(5000); + } + if (!retries) { + NLOGE("Failed to read device status"); return APP_ERROR_IO; } NLOGV("%d: query status 0x%08x ulen 0x%04x", __LINE__, status, ulen); |