diff options
author | Christian Pointner <equinox@mur.at> | 2013-10-01 11:54:58 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2013-10-01 11:54:58 +0000 |
commit | 6a4d1de2083f6412da45b485a51f769726b32202 (patch) | |
tree | e1ba49306cd9b7a573e4a37cad283575b7ffadaf /software/mpu/usb-cdc-shell.c | |
parent | implemented system shutdown and reboot (not yet finished) (diff) |
added patch for chibios to implement shutdown and reboot
added shutdown and reboot to the CDC shell
git-svn-id: https://svn.spreadspace.org/mur.sat@847 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/mpu/usb-cdc-shell.c')
-rw-r--r-- | software/mpu/usb-cdc-shell.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/software/mpu/usb-cdc-shell.c b/software/mpu/usb-cdc-shell.c index c36ca19..ce62ce4 100644 --- a/software/mpu/usb-cdc-shell.c +++ b/software/mpu/usb-cdc-shell.c @@ -176,22 +176,24 @@ static int8_t shell_return_code; #define SHELL_WA_SIZE THD_WA_SIZE(2048) #define TEST_WA_SIZE THD_WA_SIZE(256) -static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) { size_t n, size; (void)argv; if (argc > 0) { chprintf(chp, "Usage: mem\r\n"); - return; + return SHELL_CMD_CONTINUE; } n = chHeapStatus(NULL, &size); chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus()); chprintf(chp, "heap fragments : %u\r\n", n); chprintf(chp, "heap free total : %u bytes\r\n", size); + + return SHELL_CMD_CONTINUE; } -static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) { static const char *states[] = {THD_STATE_NAMES}; Thread *tp; @@ -199,7 +201,7 @@ static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) (void)argv; if (argc > 0) { chprintf(chp, "Usage: threads\r\n"); - return; + return SHELL_CMD_CONTINUE; } chprintf(chp, " addr stack prio refs state time name\r\n"); tp = chRegFirstThread(); @@ -211,60 +213,67 @@ static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) (tp->p_name == NULL) ? "-" : tp->p_name); tp = chRegNextThread(tp); } while (tp != NULL); + + return SHELL_CMD_CONTINUE; } -static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { Thread *tp; (void)argv; if (argc > 0) { chprintf(chp, "Usage: test\r\n"); - return; + return SHELL_CMD_CONTINUE; } tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(), TestThread, chp); if (tp == NULL) { chprintf(chp, "out of memory\r\n"); - return; + return SHELL_CMD_CONTINUE; } chThdWait(tp); + + return SHELL_CMD_CONTINUE; } -static void cmd_halt(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_halt(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { chprintf(chp, "Usage: halt\r\n"); - return; + return SHELL_CMD_CONTINUE; } shell_return_code = MPU_HALT; chprintf(chp, "halting system.\r\n"); - /* TODO: tell shell to terminate - but how??? */ + + return SHELL_CMD_EXIT; } -static void cmd_reboot(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_reboot(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { chprintf(chp, "Usage: reboot\r\n"); - return; + return SHELL_CMD_CONTINUE; } shell_return_code = MPU_REBOOT; chprintf(chp, "rebooting system ...\r\n"); - /* TODO: tell shell to terminate - but how??? */ + + return SHELL_CMD_EXIT; } -static void cmd_bootloader(BaseSequentialStream *chp, int argc, char *argv[]) +static int8_t cmd_bootloader(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { chprintf(chp, "Usage: bootloader\r\n"); - return; + return SHELL_CMD_CONTINUE; } shell_return_code = MPU_BOOTLOADER; chprintf(chp, "rebooting to bootloader ...\r\n"); - /* TODO: tell shell to terminate - but how??? */ + + return SHELL_CMD_EXIT; } static const ShellCommand commands[] = { |