You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/02/09 02:14:24 UTC

[1/2] incubator-mynewt-larva git commit: Make shell input line length configurable.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 2994b58ce -> 7ffc25f9f


Make shell input line length configurable.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/5bf786aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/5bf786aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/5bf786aa

Branch: refs/heads/master
Commit: 5bf786aae0495885fcf55d9523de364c51b3d9dd
Parents: 2994b58
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Feb 8 17:03:02 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Feb 8 17:03:02 2016 -0800

----------------------------------------------------------------------
 libs/shell/include/shell/shell.h |  3 ++-
 libs/shell/src/shell.c           | 25 ++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5bf786aa/libs/shell/include/shell/shell.h
----------------------------------------------------------------------
diff --git a/libs/shell/include/shell/shell.h b/libs/shell/include/shell/shell.h
index af84dbd..283d70a 100644
--- a/libs/shell/include/shell/shell.h
+++ b/libs/shell/include/shell/shell.h
@@ -42,6 +42,7 @@ int shell_nlip_input_register(shell_nlip_input_func_t nf, void *arg);
 int shell_nlip_output(struct os_mbuf *m);
 
 void shell_console_rx_cb(int full_line);
-int shell_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size);
+int shell_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size,
+                    int max_input_length);
 
 #endif /* __SHELL_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5bf786aa/libs/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/libs/shell/src/shell.c b/libs/shell/src/shell.c
index d5a3c96..7c939c3 100644
--- a/libs/shell/src/shell.c
+++ b/libs/shell/src/shell.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include <errno.h>
 
 static shell_nlip_input_func_t g_shell_nlip_in_func;
 static void *g_shell_nlip_in_arg;
@@ -48,7 +49,8 @@ static struct os_event console_rdy_ev;
 
 static struct os_mutex g_shell_cmd_list_lock; 
 
-static char shell_line[1024];
+static char *shell_line;
+static int shell_line_capacity;
 static int shell_line_len;
 static char *argv[20];
 static uint8_t shell_full_line;
@@ -368,7 +370,7 @@ shell_read_console(void)
 
     while (1) {
         rc = console_read(shell_line + shell_line_len,
-                          sizeof(shell_line) - shell_line_len);
+                          shell_line_capacity - shell_line_len);
         if (rc < 0) {
             goto err;
         }
@@ -495,10 +497,22 @@ shell_help_cmd(int argc, char **argv)
 }
 
 int 
-shell_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size)
+shell_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size,
+                int max_input_length)
 {
     int rc;
-   
+
+    free(shell_line);
+
+    if (max_input_length > 0) {
+        shell_line = malloc(max_input_length);
+        if (shell_line == NULL) {
+            rc = ENOMEM;
+            goto err;
+        }
+    }
+    shell_line_capacity = max_input_length;
+
     rc = os_mutex_init(&g_shell_cmd_list_lock);
     if (rc != 0) {
         goto err;
@@ -534,6 +548,7 @@ shell_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size)
 
     return (0);
 err:
+    free(shell_line);
+    shell_line = NULL;
     return (rc);
 }
-


[2/2] incubator-mynewt-larva git commit: Update projects to use new shell init interface.

Posted by cc...@apache.org.
Update projects to use new shell init interface.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/7ffc25f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/7ffc25f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/7ffc25f9

Branch: refs/heads/master
Commit: 7ffc25f9f19dbfb7f74dc0a112f84e83c4759aff
Parents: 5bf786a
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Feb 8 17:10:47 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Feb 8 17:10:47 2016 -0800

----------------------------------------------------------------------
 project/bleshell/src/main.c | 4 +++-
 project/bletest/src/main.c  | 6 +++++-
 project/bletiny/src/main.c  | 8 +++++---
 project/blinky/src/main.c   | 4 +++-
 project/luatest/src/main.c  | 4 +++-
 project/slinky/src/main.c   | 4 +++-
 6 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/bleshell/src/main.c
----------------------------------------------------------------------
diff --git a/project/bleshell/src/main.c b/project/bleshell/src/main.c
index 1bb6f03..0f15f5a 100755
--- a/project/bleshell/src/main.c
+++ b/project/bleshell/src/main.c
@@ -47,6 +47,7 @@
 #define HOST_TASK_PRIO          (1)
 
 #define SHELL_TASK_PRIO         (3)
+#define SHELL_MAX_INPUT_LEN     (1024)
 #define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(384))
 static bssnz_t os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
@@ -1322,7 +1323,8 @@ main(void)
     /* Initialize the BLE LL */
     ble_ll_init();
 
-    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
     assert(rc == 0);
 
     /* Init the console */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
index 2acb903..7970f77 100755
--- a/project/bletest/src/main.c
+++ b/project/bletest/src/main.c
@@ -63,6 +63,9 @@ os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
 /* Flash file system sector size */
 #define NFFS_AREA_MAX       (8)
 
+/* Shell maximum input line length */
+#define SHELL_MAX_INPUT_LEN     (256)
+
 /* For LED toggling */
 int g_led_pin;
 
@@ -892,7 +895,8 @@ main(void)
         assert(rc == 0);
     }
 
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
 
     nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE);
     imgmgr_module_init();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/main.c b/project/bletiny/src/main.c
index b822095..1a8ad4d 100755
--- a/project/bletiny/src/main.c
+++ b/project/bletiny/src/main.c
@@ -47,7 +47,8 @@
 #define HOST_TASK_PRIO          (1)
 
 #define SHELL_TASK_PRIO         (3)
-#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(128))
+#define SHELL_MAX_INPUT_LEN     (256)
+#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(96))
 static bssnz_t os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
 static struct os_mutex bletiny_mutex;
@@ -79,7 +80,7 @@ struct os_mbuf_pool default_mbuf_pool;
 struct os_mempool default_mbuf_mpool;
 
 /* BLETINY variables */
-#define BLETINY_STACK_SIZE             (96)
+#define BLETINY_STACK_SIZE             (OS_STACK_ALIGN(128))
 #define BLETINY_TASK_PRIO              (HOST_TASK_PRIO + 1)
 
 #define BLETINY_MAX_SVCS               1
@@ -1331,7 +1332,8 @@ main(void)
     /* Initialize the BLE LL */
     ble_ll_init();
 
-    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
     assert(rc == 0);
 
     /* Init the console */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/blinky/src/main.c
----------------------------------------------------------------------
diff --git a/project/blinky/src/main.c b/project/blinky/src/main.c
index ba13490..e2d7481 100755
--- a/project/blinky/src/main.c
+++ b/project/blinky/src/main.c
@@ -48,6 +48,7 @@ struct os_task task2;
 os_stack_t stack2[TASK2_STACK_SIZE];
 
 #define SHELL_TASK_PRIO (3)
+#define SHELL_MAX_INPUT_LEN     (256)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
 os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
@@ -181,7 +182,8 @@ main(int argc, char **argv)
     rc = os_msys_register(&default_mbuf_pool);
     assert(rc == 0);
 
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                    SHELL_MAX_INPUT_LEN);
 
     (void) console_init(shell_console_rx_cb);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/luatest/src/main.c
----------------------------------------------------------------------
diff --git a/project/luatest/src/main.c b/project/luatest/src/main.c
index 7067e54..c1749d0 100755
--- a/project/luatest/src/main.c
+++ b/project/luatest/src/main.c
@@ -36,6 +36,7 @@ int init_tasks(void);
 
 /* Shell */
 #define SHELL_TASK_PRIO      (8)
+#define SHELL_MAX_INPUT_LEN     (256)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
@@ -87,7 +88,8 @@ main(int argc, char **argv)
     os_init();
 
     /* Init tasks */
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                         SHELL_MAX_INPUT_LEN);
     console_init(shell_console_rx_cb);
 
     nffs_init();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7ffc25f9/project/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/project/slinky/src/main.c b/project/slinky/src/main.c
index ce10969..7e08d2f 100755
--- a/project/slinky/src/main.c
+++ b/project/slinky/src/main.c
@@ -56,6 +56,7 @@ struct os_task task2;
 os_stack_t stack2[TASK2_STACK_SIZE];
 
 #define SHELL_TASK_PRIO (3)
+#define SHELL_MAX_INPUT_LEN     (256)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
 os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
@@ -265,7 +266,8 @@ main(int argc, char **argv)
         assert(rc == 0);
     }
 
-    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
+    shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
+                    SHELL_MAX_INPUT_LEN);
 
     (void) console_init(shell_console_rx_cb);