diff --git a/examples/default/Makefile b/examples/default/Makefile index 4a6fd8ee64c0..245c9c046481 100644 --- a/examples/default/Makefile +++ b/examples/default/Makefile @@ -29,7 +29,6 @@ QUIET ?= 1 # Modules to include: -USEMODULE += uart0 USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps diff --git a/examples/default/main.c b/examples/default/main.c index df24568dce5c..d7ffc937f390 100644 --- a/examples/default/main.c +++ b/examples/default/main.c @@ -26,10 +26,8 @@ #include #include "thread.h" -#include "posix_io.h" #include "shell.h" #include "shell_commands.h" -#include "board_uart0.h" #if FEATURE_PERIPH_RTC #include "periph/rtc.h" @@ -41,9 +39,6 @@ int main(void) { - shell_t shell; - (void) posix_open(uart0_handler_pid, 0); - #ifdef MODULE_LTC4150 ltc4150_start(); #endif @@ -54,8 +49,8 @@ int main(void) (void) puts("Welcome to RIOT!"); - shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); - shell_run(&shell); return 0; } diff --git a/examples/gnrc_networking/Makefile b/examples/gnrc_networking/Makefile index 3347e0ce677b..b42bdf10a2fb 100644 --- a/examples/gnrc_networking/Makefile +++ b/examples/gnrc_networking/Makefile @@ -28,8 +28,7 @@ USEMODULE += gnrc_rpl USEMODULE += gnrc_pktdump # Additional networking modules that can be dropped if not needed USEMODULE += gnrc_icmpv6_echo -# Add also the shell, some shell commands (which are based on uart0 in this app) -USEMODULE += uart0 +# Add also the shell, some shell commands USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps diff --git a/examples/gnrc_networking/main.c b/examples/gnrc_networking/main.c index b686ad97e2ec..c3c66f9978a3 100644 --- a/examples/gnrc_networking/main.c +++ b/examples/gnrc_networking/main.c @@ -21,8 +21,6 @@ #include #include "shell.h" -#include "board_uart0.h" -#include "posix_io.h" extern int udp_cmd(int argc, char **argv); @@ -33,15 +31,12 @@ static const shell_command_t shell_commands[] = { int main(void) { - shell_t shell; - puts("RIOT network stack example application"); /* start shell */ puts("All up, running the shell now"); - posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); /* should be never reached */ return 0; diff --git a/tests/driver_at86rf2xx/Makefile b/tests/driver_at86rf2xx/Makefile index 9cfba5f54dfe..1f375e39dbf2 100644 --- a/tests/driver_at86rf2xx/Makefile +++ b/tests/driver_at86rf2xx/Makefile @@ -65,7 +65,6 @@ USEMODULE += auto_init_gnrc_netif USEMODULE += gnrc_netif USEMODULE += gnrc_nomac USEMODULE += gnrc_pktdump -USEMODULE += uart0 USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps diff --git a/tests/driver_at86rf2xx/main.c b/tests/driver_at86rf2xx/main.c index 40efb9bbd367..06c7bf491782 100644 --- a/tests/driver_at86rf2xx/main.c +++ b/tests/driver_at86rf2xx/main.c @@ -22,22 +22,14 @@ #include "shell.h" #include "shell_commands.h" -#include "posix_io.h" -#include "board_uart0.h" #include "net/gnrc/pktdump.h" #include "net/gnrc.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - /** * @brief Maybe you are a golfer?! */ int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("AT86RF2xx device driver test"); @@ -50,9 +42,9 @@ int main(void) /* start the shell */ puts("Initialization successful - starting the shell now"); - (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_kw2xrf/Makefile b/tests/driver_kw2xrf/Makefile index 81fdb4d097c0..a49920547697 100644 --- a/tests/driver_kw2xrf/Makefile +++ b/tests/driver_kw2xrf/Makefile @@ -54,7 +54,6 @@ USEMODULE += auto_init_gnrc_netif USEMODULE += gnrc_netif USEMODULE += gnrc_nomac USEMODULE += gnrc_pktdump -USEMODULE += uart0 USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps diff --git a/tests/driver_kw2xrf/main.c b/tests/driver_kw2xrf/main.c index f3047dfd2bed..2591bdfdd086 100644 --- a/tests/driver_kw2xrf/main.c +++ b/tests/driver_kw2xrf/main.c @@ -21,19 +21,11 @@ #include "shell.h" #include "shell_commands.h" -#include "posix_io.h" -#include "board_uart0.h" #include "net/gnrc.h" #include "net/gnrc/pktdump.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("KW2XRF device driver test"); @@ -46,9 +38,9 @@ int main(void) /* start the shell */ puts("Initialization successful - starting the shell now"); - (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_netdev_eth/main.c b/tests/driver_netdev_eth/main.c index d4d817ebe60d..f9dabde9ec07 100644 --- a/tests/driver_netdev_eth/main.c +++ b/tests/driver_netdev_eth/main.c @@ -33,17 +33,11 @@ #include "net/dev_eth.h" #include "dev_eth_tap.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - /** * @brief Maybe you are a golfer?! */ int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("netdev ethernet device driver test"); @@ -60,8 +54,8 @@ int main(void) gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump); /* start the shell */ - shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_nrf24l01p_lowlevel/main.c b/tests/driver_nrf24l01p_lowlevel/main.c index 4913d89ffa04..42c8e7629c72 100644 --- a/tests/driver_nrf24l01p_lowlevel/main.c +++ b/tests/driver_nrf24l01p_lowlevel/main.c @@ -51,8 +51,6 @@ #define TEST_RX_MSG 1 -#define SHELL_BUFFER_SIZE 128 - static int cmd_send(int argc, char **argv); static int cmd_print_regs(int argc, char **argv); static int cmd_its(int argc, char **argv); @@ -325,14 +323,10 @@ int cmd_print_regs(int argc, char **argv) int main(void) { - shell_t shell; - puts("Welcome to RIOT!"); - puts("Initializing shell..."); - shell_init(&shell, shell_commands, SHELL_BUFFER_SIZE, getchar, putchar); - puts("Starting shell..."); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_nrfmin/Makefile b/tests/driver_nrfmin/Makefile index b082b0dbd124..11b3bba8e99d 100644 --- a/tests/driver_nrfmin/Makefile +++ b/tests/driver_nrfmin/Makefile @@ -6,7 +6,6 @@ FEATURES_REQUIRED = radio_nrfmin USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps -USEMODULE += uart0 USEMODULE += radio_nrfmin USEMODULE += gnrc USEMODULE += gnrc_nomac diff --git a/tests/driver_nrfmin/main.c b/tests/driver_nrfmin/main.c index 3ad26ecb6948..5dadfc3bd4c1 100644 --- a/tests/driver_nrfmin/main.c +++ b/tests/driver_nrfmin/main.c @@ -21,20 +21,15 @@ #include #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" #include "nrfmin.h" #include "net/gnrc.h" #include "net/gnrc/nomac.h" #include "net/gnrc/pktdump.h" -#define SHELL_BUFSIZE (UART0_BUFSIZE) - static char nomac_stack[THREAD_STACKSIZE_DEFAULT]; int main(void) { - shell_t shell; gnrc_netdev_t dev; gnrc_netreg_entry_t netobj; @@ -51,10 +46,8 @@ int main(void) gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &netobj); /* initialize and run the shell */ - board_uart0_init(); - posix_open(uart0_handler_pid, 0); - shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_pcd8544/Makefile b/tests/driver_pcd8544/Makefile index 9bd3beef35d2..e83de301f7c6 100644 --- a/tests/driver_pcd8544/Makefile +++ b/tests/driver_pcd8544/Makefile @@ -3,7 +3,6 @@ include ../Makefile.tests_common FEATURES_REQUIRED = periph_gpio periph_spi -USEMODULE += uart0 USEMODULE += shell USEMODULE += pcd8544 diff --git a/tests/driver_pcd8544/main.c b/tests/driver_pcd8544/main.c index 56bbcf2ca6ad..58d6453f47a9 100644 --- a/tests/driver_pcd8544/main.c +++ b/tests/driver_pcd8544/main.c @@ -35,13 +35,9 @@ #include #include -#include "posix_io.h" -#include "board_uart0.h" #include "shell.h" #include "pcd8544.h" -#define SHELL_BUFSIZE (64U) - static pcd8544_t dev; static int _contrast(int argc, char **argv) @@ -158,8 +154,6 @@ static const shell_command_t shell_commands[] = { int main(void) { - shell_t shell; - puts("PCD8544 LCD display test application\n"); printf("Initializing PCD8544 LCD at SPI_%i... ", TEST_PCD8544_SPI); if (pcd8544_init(&dev, TEST_PCD8544_SPI, TEST_PCD8544_CS, @@ -170,9 +164,9 @@ int main(void) /* run shell */ puts("All OK, running shell now"); - (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/driver_xbee/main.c b/tests/driver_xbee/main.c index 22e0ffea8ddd..bf0641ae67cc 100644 --- a/tests/driver_xbee/main.c +++ b/tests/driver_xbee/main.c @@ -25,17 +25,11 @@ #include "net/gnrc.h" #include "net/gnrc/pktdump.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - /** * @brief Maybe you are a golfer?! */ int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("Xbee S1 device driver test"); @@ -51,8 +45,9 @@ int main(void) /* start the shell */ puts("Initialization OK, starting shell now"); - shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/periph_gpio/Makefile b/tests/periph_gpio/Makefile index d987ff764639..e71e3a0fc8aa 100644 --- a/tests/periph_gpio/Makefile +++ b/tests/periph_gpio/Makefile @@ -3,7 +3,6 @@ include ../Makefile.tests_common FEATURES_REQUIRED = periph_gpio -USEMODULE += uart0 USEMODULE += shell include $(RIOTBASE)/Makefile.include diff --git a/tests/periph_gpio/main.c b/tests/periph_gpio/main.c index b34f65d98fae..685e3a82f595 100644 --- a/tests/periph_gpio/main.c +++ b/tests/periph_gpio/main.c @@ -22,13 +22,9 @@ #include #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" #include "periph/gpio.h" #include "hwtimer.h" -#define SHELL_BUFSIZE (64U) - static void cb(void *arg) { printf("INT: external interrupt from pin %i\n", (int)arg); @@ -237,8 +233,6 @@ static const shell_command_t shell_commands[] = { int main(void) { - shell_t shell; - puts("GPIO peripheral driver test\n"); puts("In this test, pins are specified by integer port and pin numbers.\n" "So if your platform has a pin PA01, it will be port=0 and pin=1,\n" @@ -247,9 +241,8 @@ int main(void) " behavior for not existing ports/pins is not defined!"); /* start the shell */ - (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/periph_i2c/Makefile b/tests/periph_i2c/Makefile index 91eb06be1b30..56e66531fd63 100644 --- a/tests/periph_i2c/Makefile +++ b/tests/periph_i2c/Makefile @@ -4,6 +4,5 @@ include ../Makefile.tests_common FEATURES_REQUIRED = periph_i2c USEMODULE += shell -USEMODULE += uart0 include $(RIOTBASE)/Makefile.include diff --git a/tests/periph_i2c/main.c b/tests/periph_i2c/main.c index a01780fff442..cd6226ab979c 100644 --- a/tests/periph_i2c/main.c +++ b/tests/periph_i2c/main.c @@ -24,8 +24,6 @@ #include "periph_conf.h" #include "periph/i2c.h" #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" #define BUFSIZE (128U) @@ -306,17 +304,11 @@ static const shell_command_t shell_commands[] = { int main(void) { - shell_t shell; - puts("Test for the low-level I2C driver"); - /* prepare I/O for shell */ - board_uart0_init(); - (void) posix_open(uart0_handler_pid, 0); - /* define own shell commands */ - shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/periph_spi/main.c b/tests/periph_spi/main.c index 8e2196621c82..c04a20bdfa93 100644 --- a/tests/periph_spi/main.c +++ b/tests/periph_spi/main.c @@ -29,8 +29,6 @@ #include "periph/spi.h" #include "periph/gpio.h" -#define SHELL_BUFSIZE (128U) - enum { READ = 0, WRITE, @@ -288,15 +286,13 @@ static const shell_command_t shell_commands[] = { int main(void) { - shell_t shell; - puts("\nRIOT low-level SPI driver test"); puts("This application enables you to test a platforms SPI driver implementation."); puts("Enter 'help' to get started\n"); /* run the shell */ - shell_init(&shell, shell_commands, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/shell/Makefile b/tests/shell/Makefile index bf0b3d724304..721a5f89d29e 100644 --- a/tests/shell/Makefile +++ b/tests/shell/Makefile @@ -4,7 +4,6 @@ include ../Makefile.tests_common USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps -USEMODULE += uart0 DISABLE_MODULE += auto_init diff --git a/tests/shell/ReadMe.txt b/tests/shell/ReadMe.txt index d2f8288419ab..16bf30e2416f 100644 --- a/tests/shell/ReadMe.txt +++ b/tests/shell/ReadMe.txt @@ -1,15 +1,14 @@ This application shows how to use own or the system shell commands. In order to use the system shell commands: -1. Additionally to the module: shell, shell_commands and posix, +1. Additionally to the module: shell, shell_commands, the module for the corresponding system command is to include, e.g. module ps for the ps command (cf. the Makefile in the application root directory). -2. The shell must be initialized as follows: - 2.1 shell_t sys_shell; - 2.2 shell_init(&shell, shell_commands, shell_bufsize, shell_readc, - shell_putchar); - or shell_init(&sys_shell, NULL, shell_bufsize, - shell_readc, shell_putchar); - /* to initialize without the built-in shell commands */ - 2.3 shell_run(&sys_shell); +2. Start the shell like this: + 2.1 reserve buffer: + char line_buf[SHELL_DEFAULT_BUFSIZE]; + 2.1a run shell only with system commands: + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + 2.1b run shell with provided commands in addition to system commands: + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); diff --git a/tests/shell/main.c b/tests/shell/main.c index 7bd4850f47e4..c4d59cb77a27 100644 --- a/tests/shell/main.c +++ b/tests/shell/main.c @@ -22,11 +22,7 @@ #include #include "shell_commands.h" -#include "posix_io.h" #include "shell.h" -#include "board_uart0.h" - -#define SHELL_BUFSIZE (UART0_BUFSIZE) static int print_teststart(int argc, char **argv) { @@ -68,20 +64,16 @@ int main(void) printf("test_shell.\n"); - board_uart0_init(); - posix_open(uart0_handler_pid, 0); + /* define buffer to be used by the shell */ + char line_buf[SHELL_DEFAULT_BUFSIZE]; /* define own shell commands */ - shell_t shell; - shell_init(&shell, shell_commands, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); /* or use only system shell commands */ /* - shell_t sys_shell; - shell_init(&sys_shell, NULL, SHELL_BUFSIZE, shell_readc, shell_putchar); - shell_run(&sys_shell); + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); */ return 0; diff --git a/tests/slip/main.c b/tests/slip/main.c index 4958789d6a97..a600fa2a5479 100644 --- a/tests/slip/main.c +++ b/tests/slip/main.c @@ -25,17 +25,11 @@ #include "net/gnrc.h" #include "net/gnrc/pktdump.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - /** * @brief Maybe you are a golfer?! */ int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("SLIP test"); @@ -53,8 +47,9 @@ int main(void) /* start the shell */ puts("Initialization OK, starting shell now"); - shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/struct_tm_utility/Makefile b/tests/struct_tm_utility/Makefile index 6882bf4b165e..4a9db06daf03 100644 --- a/tests/struct_tm_utility/Makefile +++ b/tests/struct_tm_utility/Makefile @@ -4,7 +4,6 @@ include ../Makefile.tests_common DISABLE_MODULE += auto_init USEMODULE += shell -USEMODULE += uart0 USEMODULE += timex # The MSP-430 toolchain lacks sscanf: diff --git a/tests/struct_tm_utility/main.c b/tests/struct_tm_utility/main.c index bf2791d10507..eb9176a94e7a 100644 --- a/tests/struct_tm_utility/main.c +++ b/tests/struct_tm_utility/main.c @@ -30,12 +30,8 @@ #include #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" #include "tm.h" -#define SHELL_BUFSIZE (UART0_BUFSIZE) - static const char MON_NAMES[12][3] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", @@ -136,14 +132,10 @@ static const shell_command_t shell_commands[] = { int main(void) { - board_uart0_init(); - posix_open(uart0_handler_pid, 0); - - shell_t shell; - shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc); - puts("`struct tm` utility shell."); - shell_run(&shell); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/tests/zep/main.c b/tests/zep/main.c index ab0cdff26d8e..da9aacbed43c 100644 --- a/tests/zep/main.c +++ b/tests/zep/main.c @@ -25,33 +25,11 @@ #include "net/gnrc.h" #include "net/gnrc/pktdump.h" -/** - * @brief Buffer size used by the shell - */ -#define SHELL_BUFSIZE (64U) - -/** - * @brief Read chars from STDIO - */ -int shell_read(void) -{ - return (int)getchar(); -} - -/** - * @brief Write chars to STDIO - */ -void shell_put(int c) -{ - putchar((char)c); -} - /** * @brief Maybe you are a golfer?! */ int main(void) { - shell_t shell; gnrc_netreg_entry_t dump; puts("ZEP module test"); @@ -69,8 +47,8 @@ int main(void) /* start the shell */ puts("Initialization OK, starting shell now"); - shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); - shell_run(&shell); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }