Browse Source

tests, examples: adapt to simplified shell

dev/timer
Kaspar Schleiser 7 years ago
parent
commit
25f900e489
  1. 1
      examples/default/Makefile
  2. 9
      examples/default/main.c
  3. 3
      examples/gnrc_networking/Makefile
  4. 9
      examples/gnrc_networking/main.c
  5. 1
      tests/driver_at86rf2xx/Makefile
  6. 14
      tests/driver_at86rf2xx/main.c
  7. 1
      tests/driver_kw2xrf/Makefile
  8. 14
      tests/driver_kw2xrf/main.c
  9. 10
      tests/driver_netdev_eth/main.c
  10. 10
      tests/driver_nrf24l01p_lowlevel/main.c
  11. 1
      tests/driver_nrfmin/Makefile
  12. 11
      tests/driver_nrfmin/main.c
  13. 1
      tests/driver_pcd8544/Makefile
  14. 12
      tests/driver_pcd8544/main.c
  15. 11
      tests/driver_xbee/main.c
  16. 1
      tests/periph_gpio/Makefile
  17. 11
      tests/periph_gpio/main.c
  18. 1
      tests/periph_i2c/Makefile
  19. 12
      tests/periph_i2c/main.c
  20. 8
      tests/periph_spi/main.c
  21. 1
      tests/shell/Makefile
  22. 17
      tests/shell/ReadMe.txt
  23. 16
      tests/shell/main.c
  24. 11
      tests/slip/main.c
  25. 1
      tests/struct_tm_utility/Makefile
  26. 14
      tests/struct_tm_utility/main.c
  27. 26
      tests/zep/main.c

1
examples/default/Makefile

@ -29,7 +29,6 @@ QUIET ?= 1
# Modules to include:
USEMODULE += uart0
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps

9
examples/default/main.c

@ -26,10 +26,8 @@
#include <string.h>
#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;
}

3
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

9
examples/gnrc_networking/main.c

@ -21,8 +21,6 @@
#include <stdio.h>
#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;

1
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

14
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;
}

1
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

14
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;
}

10
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;
}

10
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;
}

1
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

11
tests/driver_nrfmin/main.c

@ -21,20 +21,15 @@
#include <stdio.h>
#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;
}

1
tests/driver_pcd8544/Makefile

@ -3,7 +3,6 @@ include ../Makefile.tests_common
FEATURES_REQUIRED = periph_gpio periph_spi
USEMODULE += uart0
USEMODULE += shell
USEMODULE += pcd8544

12
tests/driver_pcd8544/main.c

@ -35,13 +35,9 @@
#include <string.h>
#include <stdlib.h>
#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;
}

11
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;
}

1
tests/periph_gpio/Makefile

@ -3,7 +3,6 @@ include ../Makefile.tests_common
FEATURES_REQUIRED = periph_gpio
USEMODULE += uart0
USEMODULE += shell
include $(RIOTBASE)/Makefile.include

11
tests/periph_gpio/main.c

@ -22,13 +22,9 @@
#include <stdlib.h>
#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;
}

1
tests/periph_i2c/Makefile

@ -4,6 +4,5 @@ include ../Makefile.tests_common
FEATURES_REQUIRED = periph_i2c
USEMODULE += shell
USEMODULE += uart0
include $(RIOTBASE)/Makefile.include

12
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;
}

8
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;
}

1
tests/shell/Makefile

@ -4,7 +4,6 @@ include ../Makefile.tests_common
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += uart0
DISABLE_MODULE += auto_init

17
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);

16
tests/shell/main.c

@ -22,11 +22,7 @@
#include <string.h>
#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;

11
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;
}

1
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:

14
tests/struct_tm_utility/main.c

@ -30,12 +30,8 @@
#include <stdbool.h>
#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;
}

26
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;
}

Loading…
Cancel
Save