You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/08 16:14:51 UTC
[incubator-nuttx-apps] branch master updated: system/adb: fix shell
issue and add reboot feature
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new d37a1d2 system/adb: fix shell issue and add reboot feature
d37a1d2 is described below
commit d37a1d2f1bf5aaf4c1d4fcc8d06d3b9c36d4e25b
Author: Simon Piriou <sp...@gmail.com>
AuthorDate: Tue Dec 8 14:16:57 2020 +0100
system/adb: fix shell issue and add reboot feature
---
system/adb/Makefile | 2 +-
system/adb/adb_main.c | 9 +++++++++
system/adb/shell_pipe.c | 31 ++++++++++++++++++++++++++-----
system/adb/shell_service.c | 11 +++++++----
4 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/system/adb/Makefile b/system/adb/Makefile
index f5e7778..4abcee0 100644
--- a/system/adb/Makefile
+++ b/system/adb/Makefile
@@ -22,7 +22,7 @@ include $(APPDIR)/Make.defs
ADB_DIR := $(APPDIR)/system/adb
CONFIG_ADBD_URL ?= "https://github.com/spiriou/microADB.git"
-CONFIG_ADBD_VERSION ?= bbd1e74bd795aa2fc53eae2b76bff993d6ccaa37
+CONFIG_ADBD_VERSION ?= b7025c67b866925d1e64c016a844a6a3392557a4
ADB_UNPACKNAME := microADB
ADB_UNPACKDIR := $(ADB_DIR)/$(ADB_UNPACKNAME)
diff --git a/system/adb/adb_main.c b/system/adb/adb_main.c
index d80c746..e72d221 100644
--- a/system/adb/adb_main.c
+++ b/system/adb/adb_main.c
@@ -46,6 +46,15 @@ void adb_log_impl(FAR const char *func, int line, FAR const char *fmt, ...)
va_end(ap);
}
+void adb_reboot_impl(const char *target)
+{
+#ifdef CONFIG_BOARDCTL_RESET
+ boardctl(BOARDIOC_RESET, 0);
+#else
+ adb_log("reboot not implemented\n");
+#endif
+}
+
int main(int argc, FAR char **argv)
{
UNUSED(argc);
diff --git a/system/adb/shell_pipe.c b/system/adb/shell_pipe.c
index ad59b71..1cf8dc2 100644
--- a/system/adb/shell_pipe.c
+++ b/system/adb/shell_pipe.c
@@ -113,6 +113,10 @@ static void shell_pipe_close_callback(uv_handle_t *handle)
{
shell_pipe_t *pipe = container_of(handle, shell_pipe_t, handle);
+ /* Close stdout pipe */
+
+ close(pipe->write_fd);
+
/* Notify caller pipe is closed */
pipe->close_cb(pipe);
@@ -132,6 +136,12 @@ void shell_pipe_destroy(shell_pipe_t *pipe, void (*close_cb)(shell_pipe_t *))
{
pipe->close_cb = close_cb;
close(pipe->write_fd);
+
+ if (uv_fileno((const uv_handle_t *)&pipe->handle, &pipe->write_fd))
+ {
+ pipe->write_fd = -1;
+ }
+
uv_close((uv_handle_t *)&pipe->handle, shell_pipe_close_callback);
}
@@ -160,12 +170,17 @@ int shell_pipe_exec(char * const argv[], shell_pipe_t *apipe,
/* Create pipe for stdin */
- ret = pipe(in_fds);
- assert(ret == 0);
- ret = pipe(out_fds);
- assert(ret == 0);
+ if ((ret = pipe(in_fds)))
+ {
+ adb_log("failed to open in pipe %d\n", errno);
+ goto exit_fail;
+ }
- /* TODO check return code */
+ if ((ret = pipe(out_fds)))
+ {
+ adb_log("failed to open out pipe %d\n", errno);
+ goto exit_close_pipe_in;
+ }
apipe->write_fd = in_fds[1];
@@ -234,4 +249,10 @@ int shell_pipe_exec(char * const argv[], shell_pipe_t *apipe,
assert(ret == 0);
return 0;
+
+exit_close_pipe_in:
+ close(in_fds[0]);
+ close(in_fds[1]);
+exit_fail:
+ return ret;
}
diff --git a/system/adb/shell_service.c b/system/adb/shell_service.c
index 04bdfeb..c8c7e30 100644
--- a/system/adb/shell_service.c
+++ b/system/adb/shell_service.c
@@ -199,11 +199,14 @@ adb_service_t * shell_service(adb_client_t *client, const char *params)
ret = shell_pipe_exec(argv, &service->pipe,
exec_on_data_available);
- /* TODO check return code */
-
- assert(ret == 0);
-
free(argv);
+ if (ret)
+ {
+ adb_log("failed to setup shell pipe %d\n", ret);
+ free(service);
+ return NULL;
+ }
+
return &service->service;
}