diff --git a/apps/shell/gui-shell.c b/apps/shell/gui-shell.c index ac2f40c3b..73bf6f84d 100644 --- a/apps/shell/gui-shell.c +++ b/apps/shell/gui-shell.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki desktop OS. * - * $Id: gui-shell.c,v 1.1 2008/02/07 23:11:56 oliverschmidt Exp $ + * $Id: gui-shell.c,v 1.2 2008/02/08 12:49:54 oliverschmidt Exp $ * */ @@ -127,6 +127,7 @@ PROCESS_THREAD(shell_gui_process, ev, data) shell_init(); shell_file_init(); shell_ps_init(); + shell_run_init(); shell_text_init(); shell_time_init(); diff --git a/apps/shell/shell-run.c b/apps/shell/shell-run.c new file mode 100644 index 000000000..5c6bc7696 --- /dev/null +++ b/apps/shell/shell-run.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: shell-run.c,v 1.1 2008/02/08 12:49:54 oliverschmidt Exp $ + */ + +#include + +#include "contiki.h" + +#include "shell-run.h" + +/*---------------------------------------------------------------------------*/ +PROCESS(shell_run_process, "run"); +SHELL_COMMAND(run_command, + "run", + "run: load and run a PRG file", + &shell_run_process); +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(shell_run_process, ev, data) +{ + char *name, *print; + + PROCESS_BEGIN(); + + name = data; + if(name == NULL || strlen(name) == 0) { + shell_output_str(&run_command, + "run : filename must be given", ""); + PROCESS_EXIT(); + } + + switch(LOADER_LOAD(name, NULL)) { + case LOADER_OK: + print = "OK"; + break; + case LOADER_ERR_READ: + print = "Read error"; + break; + case LOADER_ERR_HDR: + print = "Header error"; + break; + case LOADER_ERR_OS: + print = "Wrong OS"; + break; + case LOADER_ERR_FMT: + print = "Data format error"; + break; + case LOADER_ERR_MEM: + print = "Not enough memory"; + break; + case LOADER_ERR_OPEN: + print = "Could not open file"; + break; + case LOADER_ERR_ARCH: + print = "Wrong architecture"; + break; + case LOADER_ERR_VERSION: + print = "Wrong OS version"; + break; + case LOADER_ERR_NOLOADER: + print = "Program loading not supported"; + break; + default: + print = "Unknown return code from the loader (internal bug)"; + break; + } + shell_output_str(&run_command, print, "."); + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ +void +shell_run_init(void) +{ + shell_register_command(&run_command); +} +/*---------------------------------------------------------------------------*/ diff --git a/apps/shell/shell-run.h b/apps/shell/shell-run.h new file mode 100644 index 000000000..4fc8ad97f --- /dev/null +++ b/apps/shell/shell-run.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: shell-run.h,v 1.1 2008/02/08 12:49:54 oliverschmidt Exp $ + */ + +#ifndef __SHELL_RUN_H__ +#define __SHELL_RUN_H__ + +#include "shell.h" + +void shell_run_init(void); + +#endif /* __SHELL_RUN_H__ */ diff --git a/apps/shell/shell.h b/apps/shell/shell.h index 1c05edb7b..b5c35915a 100644 --- a/apps/shell/shell.h +++ b/apps/shell/shell.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell.h,v 1.3 2008/02/05 12:23:32 adamdunkels Exp $ + * $Id: shell.h,v 1.4 2008/02/08 12:49:54 oliverschmidt Exp $ */ /** @@ -105,6 +105,7 @@ struct shell_input { #include "shell-rime-ping.h" #include "shell-rime-sniff.h" #include "shell-rsh.h" +#include "shell-run.h" #include "shell-sendtest.h" #include "shell-sky.h" #include "shell-text.h"