diff --git a/projects/test_shell/test_shell.c b/projects/test_shell/test_shell.c index 7499c9b85b..3605a6a68f 100644 --- a/projects/test_shell/test_shell.c +++ b/projects/test_shell/test_shell.c @@ -43,10 +43,8 @@ int main(void) { posix_open(uart0_handler_pid, 0); shell_t shell; - shell_init(&shell, shell_readc, shell_putchar); + shell_init(&shell, shell_commands, shell_readc, shell_putchar); - shell.command_list = shell_commands; - shell_run(&shell); return 0; diff --git a/projects/test_sleep/Jamfile b/projects/test_sleep/Jamfile index eee5c1fa22..83289e1e2e 100644 --- a/projects/test_sleep/Jamfile +++ b/projects/test_sleep/Jamfile @@ -1,5 +1,5 @@ SubDir TOP projects test_sleep ; -Module test_sleep : main.c : hwtimer ; +Module test_sleep : main.c : hwtimer ps ; UseModule test_sleep ; diff --git a/projects/test_sleep/main.c b/projects/test_sleep/main.c index d5e02846fe..4568b274d0 100644 --- a/projects/test_sleep/main.c +++ b/projects/test_sleep/main.c @@ -2,6 +2,7 @@ #include #include #include +#include int integer = 0; int i = 0; @@ -11,7 +12,7 @@ void second_thread(void) { while(1) { integer++; printf("sleeper: running. integer=%i, i=%i.\n", integer, i); - if (integer % 100 == 0) { + if (integer % 1 == 0) { printf("Going to sleep.\n"); thread_sleep(); } @@ -19,14 +20,12 @@ void second_thread(void) { } tcb second_thread_tcb; -char second_thread_stack[KERNEL_CONF_STACKSIZE_DEFAULT]; +char second_thread_stack[KERNEL_CONF_STACKSIZE_DEFAULT*2]; int main(void) { hwtimer_init(); - printf("Hello world!\n"); - int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper"); if (pid < 0) { @@ -37,9 +36,11 @@ int main(void) while(1) { i++; printf(" main: running. integer=%i, i=%i.\n", integer, i); - if (i % 100 == 0) { + if (i % 1 == 0) { + thread_print_all(); printf("Waking up sleeper.\n"); thread_wakeup(pid); + thread_print_all(); thread_yield(); } } diff --git a/projects/test_suite/test_suite.c b/projects/test_suite/test_suite.c index 5cfba74eb9..6133537be8 100644 --- a/projects/test_suite/test_suite.c +++ b/projects/test_suite/test_suite.c @@ -48,10 +48,8 @@ int main(void) { posix_open(uart0_handler_pid, 0); shell_t shell; - shell_init(&shell, shell_readc, shell_putchar); + shell_init(&shell, shell_commands, shell_readc, shell_putchar); - shell.command_list = shell_commands; - shell_run(&shell); return 0; diff --git a/sys/include/shell.h b/sys/include/shell.h index daa739b531..487256d444 100644 --- a/sys/include/shell.h +++ b/sys/include/shell.h @@ -34,7 +34,7 @@ and the mailinglist (subscription via web site) //#include "hashtable.h" -typedef struct shell_commant_t { +typedef struct shell_command_t { char* name; void (*handler)(char*); } shell_command_t; @@ -47,16 +47,12 @@ typedef struct shell_t { /** * @brief Initialize a shell object + * @param shell Pointer to preallocated shell object + * @param shell_commands Pointer to shell command structure. See test_shell project for example. + * @param read_char Pointer to input device read function. Should return exactly one byte or block. + * @param put_char Pointer to output funtion. currently unused, shell code will use printf. */ -void shell_init(shell_t *shell, int(*read_char)(void), void (*put_char)(int)); - -/** - * @brief Register a new command handler for a shell. - * @param shell Shell object. - * @param name Name of the command to register. - * @param handler Function pointer to handler that takes the complete command line as parameter. - */ -//void shell_register_cmd(shell_t *shell, char* name, void (*handler)(char* args)); +void shell_init(shell_t *shell, const shell_command_t *shell_commands, int(*read_char)(void), void (*put_char)(int)); /** * @brief Endless loop that waits for command and executes handler. diff --git a/sys/shell/shell.c b/sys/shell/shell.c index 3c017c1a05..f4dce41ee3 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -115,7 +115,8 @@ void shell_run(shell_t *shell) { } } -void shell_init(shell_t *shell, int(*readchar)(void), void(*put_char)(int)) { +void shell_init(shell_t *shell, const shell_command_t *shell_commands, int(*readchar)(void), void(*put_char)(int)) { + shell->command_list = shell_commands; shell->readchar = readchar; shell->put_char = put_char; }