From 0d96f5c78e54d267ef1ca230fe20af1ca090e1d6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 12:21:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5859 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/various/shell.c') diff --git a/os/various/shell.c b/os/various/shell.c index abdfc0b86..54980622e 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -103,7 +103,7 @@ static void cmd_systime(BaseSequentialStream *chp, int argc, char *argv[]) { usage(chp, "systime"); return; } - chprintf(chp, "%lu\r\n", (unsigned long)chTimeNow()); + chprintf(chp, "%lu\r\n", (unsigned long)chVTGetSystemTime()); } /** -- cgit v1.2.3 From 5901a354ef4dbc849a3f6ed9539597c27cdb3810 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 25 Aug 2013 09:37:34 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6224 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/shell.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'os/various/shell.c') diff --git a/os/various/shell.c b/os/various/shell.c index 54980622e..79aceab0e 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -32,7 +32,7 @@ /** * @brief Shell termination event source. */ -EventSource shell_terminated; +event_source_t shell_terminated; static char *_strtok(char *str, const char *delim, char **saveptr) { char *token; @@ -133,12 +133,12 @@ static bool_t cmdexec(const ShellCommand *scp, BaseSequentialStream *chp, * * @param[in] p pointer to a @p BaseSequentialStream object * @return Termination reason. - * @retval RDY_OK terminated by command. - * @retval RDY_RESET terminated by reset condition on the I/O channel. + * @retval MSG_OK terminated by command. + * @retval MSG_RESET terminated by reset condition on the I/O channel. */ static msg_t shell_thread(void *p) { int n; - msg_t msg = RDY_OK; + msg_t msg = MSG_OK; BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel; const ShellCommand *scp = ((ShellConfig *)p)->sc_commands; char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH]; @@ -203,12 +203,12 @@ static msg_t shell_thread(void *p) { */ void shellInit(void) { - chEvtInit(&shell_terminated); + chEvtObjectInit(&shell_terminated); } /** * @brief Spawns a new shell. - * @pre @p CH_USE_MALLOC_HEAP and @p CH_USE_DYNAMIC must be enabled. + * @pre @p CH_CFG_USE_HEAP and @p CH_CFG_USE_DYNAMIC must be enabled. * * @param[in] scp pointer to a @p ShellConfig object * @param[in] size size of the shell working area to be allocated @@ -216,8 +216,8 @@ void shellInit(void) { * @return A pointer to the shell thread. * @retval NULL thread creation failed because memory allocation. */ -#if CH_USE_HEAP && CH_USE_DYNAMIC -Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) { +#if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC +thread_t *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) { return chThdCreateFromHeap(NULL, size, prio, shell_thread, (void *)scp); } @@ -232,7 +232,7 @@ Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) { * @param[in] prio priority level for the new shell * @return A pointer to the shell thread. */ -Thread *shellCreateStatic(const ShellConfig *scp, void *wsp, +thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp, size_t size, tprio_t prio) { return chThdCreateStatic(wsp, size, prio, shell_thread, (void *)scp); -- cgit v1.2.3 From 3368f57424db121a96207e9ee6f5e9f746d34ca6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 3 Sep 2013 09:51:32 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/shell.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'os/various/shell.c') diff --git a/os/various/shell.c b/os/various/shell.c index 79aceab0e..907d6c187 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -73,15 +73,15 @@ static void cmd_info(BaseSequentialStream *chp, int argc, char *argv[]) { } chprintf(chp, "Kernel: %s\r\n", CH_KERNEL_VERSION); -#ifdef CH_COMPILER_NAME - chprintf(chp, "Compiler: %s\r\n", CH_COMPILER_NAME); +#ifdef PORT_COMPILER_NAME + chprintf(chp, "Compiler: %s\r\n", PORT_COMPILER_NAME); #endif chprintf(chp, "Architecture: %s\r\n", CH_ARCHITECTURE_NAME); -#ifdef CH_CORE_VARIANT_NAME - chprintf(chp, "Core Variant: %s\r\n", CH_CORE_VARIANT_NAME); +#ifdef PORT_CORE_VARIANT_NAME + chprintf(chp, "Core Variant: %s\r\n", PORT_CORE_VARIANT_NAME); #endif -#ifdef CH_PORT_INFO - chprintf(chp, "Port Info: %s\r\n", CH_PORT_INFO); +#ifdef PORT_INFO + chprintf(chp, "Port Info: %s\r\n", PORT_INFO); #endif #ifdef PLATFORM_NAME chprintf(chp, "Platform: %s\r\n", PLATFORM_NAME); -- cgit v1.2.3 From 867c7c95aa67ea1f19286c3593500214101bacd9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 5 Sep 2013 09:01:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6262 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/shell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'os/various/shell.c') diff --git a/os/various/shell.c b/os/various/shell.c index 907d6c187..62ffc5ce1 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -76,7 +76,7 @@ static void cmd_info(BaseSequentialStream *chp, int argc, char *argv[]) { #ifdef PORT_COMPILER_NAME chprintf(chp, "Compiler: %s\r\n", PORT_COMPILER_NAME); #endif - chprintf(chp, "Architecture: %s\r\n", CH_ARCHITECTURE_NAME); + chprintf(chp, "Architecture: %s\r\n", PORT_ARCHITECTURE_NAME); #ifdef PORT_CORE_VARIANT_NAME chprintf(chp, "Core Variant: %s\r\n", PORT_CORE_VARIANT_NAME); #endif @@ -115,7 +115,7 @@ static ShellCommand local_commands[] = { {NULL, NULL} }; -static bool_t cmdexec(const ShellCommand *scp, BaseSequentialStream *chp, +static bool cmdexec(const ShellCommand *scp, BaseSequentialStream *chp, char *name, int argc, char *argv[]) { while (scp->sc_name != NULL) { @@ -248,7 +248,7 @@ thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp, * @retval TRUE the channel was reset or CTRL-D pressed. * @retval FALSE operation successful. */ -bool_t shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) { +bool shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) { char *p = line; while (TRUE) { -- cgit v1.2.3 From 289c93827344bbc6953c7004bb3bd66d5799a861 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 30 Oct 2013 12:49:49 +0000 Subject: Improved shell. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6398 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/shell.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'os/various/shell.c') diff --git a/os/various/shell.c b/os/various/shell.c index 62ffc5ce1..3aeb1e10a 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -138,7 +138,6 @@ static bool cmdexec(const ShellCommand *scp, BaseSequentialStream *chp, */ static msg_t shell_thread(void *p) { int n; - msg_t msg = MSG_OK; BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel; const ShellCommand *scp = ((ShellConfig *)p)->sc_commands; char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH]; @@ -190,22 +189,39 @@ static msg_t shell_thread(void *p) { } } } - /* Atomically broadcasting the event source and terminating the thread, - there is not a chSysUnlock() because the thread terminates upon return.*/ - chSysLock(); - chEvtBroadcastI(&shell_terminated); - chThdExitS(msg); - return 0; /* Never executed.*/ + shellExit(MSG_OK); + /* Never executed, silencing a warning.*/ + return 0; } /** * @brief Shell manager initialization. + * + * @api */ void shellInit(void) { chEvtObjectInit(&shell_terminated); } +/** + * @brief Terminates the shell. + * @note Must be invoked from the command handlers. + * @note Does not return. + * + * @param[in] msg shell exit code + * + * @api + */ +void shellExit(msg_t msg) { + + /* Atomically broadcasting the event source and terminating the thread, + there is not a chSysUnlock() because the thread terminates upon return.*/ + chSysLock(); + chEvtBroadcastI(&shell_terminated); + chThdExitS(msg); +} + /** * @brief Spawns a new shell. * @pre @p CH_CFG_USE_HEAP and @p CH_CFG_USE_DYNAMIC must be enabled. @@ -215,6 +231,8 @@ void shellInit(void) { * @param[in] prio priority level for the new shell * @return A pointer to the shell thread. * @retval NULL thread creation failed because memory allocation. + * + * @api */ #if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC thread_t *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) { @@ -231,9 +249,11 @@ thread_t *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) { * @param[in] size size of the shell working area * @param[in] prio priority level for the new shell * @return A pointer to the shell thread. + * + * @api */ thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp, - size_t size, tprio_t prio) { + size_t size, tprio_t prio) { return chThdCreateStatic(wsp, size, prio, shell_thread, (void *)scp); } @@ -247,6 +267,8 @@ thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp, * @return The operation status. * @retval TRUE the channel was reset or CTRL-D pressed. * @retval FALSE operation successful. + * + * @api */ bool shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) { char *p = line; -- cgit v1.2.3