diff --git a/boards/samr21-xpro/Makefile.dep b/boards/samr21-xpro/Makefile.dep index 275b59a11250..8a7cef1bbe3c 100644 --- a/boards/samr21-xpro/Makefile.dep +++ b/boards/samr21-xpro/Makefile.dep @@ -1,7 +1,6 @@ ifneq (,$(filter gnrc_netdev_default netdev_default,$(USEMODULE))) USEMODULE += at86rf233 USEMODULE += random - USEMODULE += gnrc_lwmac endif ifneq (,$(filter saul_default,$(USEMODULE))) diff --git a/examples/default/Makefile b/examples/default/Makefile index 131d701fb04c..2d2a457e7029 100644 --- a/examples/default/Makefile +++ b/examples/default/Makefile @@ -51,15 +51,14 @@ ifneq (,$(filter $(BOARD),$(BOARD_PROVIDES_NETIF))) USEMODULE += gnrc_txtsnd # the application dumps received packets to stdout USEMODULE += gnrc_pktdump - USEMODULE += gnrc_mac - USEMODULE += gnrc_priority_pktqueue + # We use only the lower layers of the GNRC network stack, hence, we can # reduce the size of the packet buffer a bit CFLAGS += -DGNRC_PKTBUF_SIZE=512 endif FEATURES_OPTIONAL += config -#FEATURES_OPTIONAL += periph_rtc +FEATURES_OPTIONAL += periph_rtc ifneq (,$(filter msb-430,$(BOARD))) USEMODULE += sht11 diff --git a/sys/auto_init/netif/auto_init_at86rf2xx.c b/sys/auto_init/netif/auto_init_at86rf2xx.c index 5f95eca47d21..3ba28a4d1db4 100644 --- a/sys/auto_init/netif/auto_init_at86rf2xx.c +++ b/sys/auto_init/netif/auto_init_at86rf2xx.c @@ -59,11 +59,19 @@ void auto_init_at86rf2xx(void) LOG_ERROR("[auto_init_netif] error initializing at86rf2xx radio #%u\n", i); } else { +#ifdef MODULE_GNRC_LWMAC gnrc_lwmac_init(_at86rf2xx_stacks[i], AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_PRIO, "at86rf2xx-lwmac", &gnrc_adpt[i]); +# else + gnrc_netdev2_init(_at86rf2xx_stacks[i], + AT86RF2XX_MAC_STACKSIZE, + AT86RF2XX_MAC_PRIO, + "at86rf2xx", + &gnrc_adpt[i]); +#endif } } } diff --git a/tests/lw_mac/Makefile b/tests/lw_mac/Makefile new file mode 100644 index 000000000000..9d1377852ce6 --- /dev/null +++ b/tests/lw_mac/Makefile @@ -0,0 +1,88 @@ +# name of your application +APPLICATION = default + +# If no BOARD is found in the environment, use this default: +BOARD ?= native + +# This has to be the absolute path to the RIOT base directory: +RIOTBASE ?= $(CURDIR)/../.. + +# Uncomment these lines if you want to use platform support from external +# repositories: +#RIOTCPU ?= $(CURDIR)/../../RIOT/thirdparty_cpu +#RIOTBOARD ?= $(CURDIR)/../../RIOT/thirdparty_boards + +# Uncomment this to enable scheduler statistics for ps: +#CFLAGS += -DSCHEDSTATISTICS + +# If you want to use native with valgrind, you should recompile native +# with the target all-valgrind instead of all: +# make -B clean all-valgrind + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +CFLAGS += -DDEVELHELP + +# Change this to 0 show compiler invocation lines by default: +QUIET ?= 1 + +# Modules to include: +USEMODULE += shell +USEMODULE += shell_commands +USEMODULE += ps +# include and auto-initialize all available sensors +USEMODULE += saul_default + +BOARD_PROVIDES_NETIF := airfy-beacon cc2538dk fox iotlab-m3 iotlab-a8-m3 mulle \ + microbit native nrf51dongle nrf52dk nrf6310 openmote-cc2538 pba-d-01-kw2x \ + pca10000 pca10005 remote-pa remote-reva saml21-xpro samr21-xpro \ + spark-core telosb yunjia-nrf51822 z1 + +ifneq (,$(filter $(BOARD),$(BOARD_PROVIDES_NETIF))) + # Use modules for networking + # gnrc is a meta module including all required, basic gnrc networking modules + USEMODULE += gnrc + # use the default network interface for the board + USEMODULE += gnrc_netdev_default + # automatically initialize the network interface + USEMODULE += auto_init_gnrc_netif + # shell command to send L2 packets with a simple string + USEMODULE += gnrc_txtsnd + # the application dumps received packets to stdout + USEMODULE += gnrc_pktdump + USEMODULE += gnrc_mac + USEMODULE += gnrc_priority_pktqueue + USEMODULE += gnrc_lwmac + # We use only the lower layers of the GNRC network stack, hence, we can + # reduce the size of the packet buffer a bit + CFLAGS += -DGNRC_PKTBUF_SIZE=512 +endif + +FEATURES_OPTIONAL += config +#FEATURES_OPTIONAL += periph_rtc + +ifneq (,$(filter msb-430,$(BOARD))) + USEMODULE += sht11 +endif +ifneq (,$(filter msba2,$(BOARD))) + USEMODULE += sht11 + USEMODULE += mci + USEMODULE += random +endif + +include $(RIOTBASE)/Makefile.include + +# Set a custom channel if needed +ifneq (,$(filter cc110x,$(USEMODULE))) # radio is cc110x sub-GHz + DEFAULT_CHANNEL ?= 0 + CFLAGS += -DCC110X_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) +else + ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz + DEFAULT_CHANNEL ?= 5 + CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL) + else # radio is IEEE 802.15.4 2.4 GHz + DEFAULT_CHANNEL ?= 26 + CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) + endif +endif diff --git a/tests/lw_mac/README.md b/tests/lw_mac/README.md new file mode 100644 index 000000000000..42bbb5f143e6 --- /dev/null +++ b/tests/lw_mac/README.md @@ -0,0 +1,110 @@ +examples/default +================ +This application is a showcase for RIOT's hardware support. Using it +for your board, you should be able to interactively use any hardware +that is supported. + +To do this, the application uses the `shell` and `shell_commands` +modules and all the driver modules each board supports. + +`shell` is a very simple interactive command interpreter that can be +used to call functions. Many of RIOT's modules define some generic +shell commands. These are included via the `shell_commands` module. + +Additionally, the `ps` module which provides the `ps` shell command is +included. + +Usage +===== + +Build, flash and start the application: +``` +export BOARD=your_board +make +make flash +make term +``` + +The `term` make target starts a terminal emulator for your board. It +connects to a default port so you can interact with the shell, usually +that is `/dev/ttyUSB0`. If your port is named differently, the +`PORT=/dev/yourport` variable can be used to override this. + + +Example output +============== + +The shell commands come with online help. Call `help` to see which commands +exist and what they do. + +Running the `help` command on an iotlab-m3: +``` +2015-09-16 16:57:17,723 - INFO # help +2015-09-16 16:57:17,725 - INFO # Command Description +2015-09-16 16:57:17,726 - INFO # --------------------------------------- +2015-09-16 16:57:17,727 - INFO # reboot Reboot the node +2015-09-16 16:57:17,729 - INFO # ps Prints information about running threads. +2015-09-16 16:57:17,731 - INFO # isl29020_init Initializes the isl29020 sensor driver. +2015-09-16 16:57:17,733 - INFO # isl29020_read Prints data from the isl29020 sensor. +2015-09-16 16:57:17,735 - INFO # lps331ap_init Initializes the lps331ap sensor driver. +2015-09-16 16:57:17,737 - INFO # lps331ap_read Prints data from the lps331ap sensor. +2015-09-16 16:57:17,739 - INFO # l3g4200d_init Initializes the l3g4200d sensor driver. +2015-09-16 16:57:17,740 - INFO # l3g4200d_read Prints data from the l3g4200d sensor. +2015-09-16 16:57:17,742 - INFO # lsm303dlhc_init Initializes the lsm303dlhc sensor driver. +2015-09-16 16:57:17,744 - INFO # lsm303dlhc_read Prints data from the lsm303dlhc sensor. +2015-09-16 16:57:17,746 - INFO # ifconfig Configure network interfaces +2015-09-16 16:57:17,747 - INFO # txtsnd Sends a custom string as is over the link layer +``` + +Running the `ps` command on an iotlab-m3: + +``` +2015-09-16 16:57:57,634 - INFO # ps +2015-09-16 16:57:57,637 - INFO # pid | name | state Q | pri | stack ( used) | location +2015-09-16 16:57:57,640 - INFO # 1 | idle | pending Q | 15 | 256 ( 140) | 0x20000200 +2015-09-16 16:57:57,642 - INFO # 2 | main | pending Q | 7 | 1536 ( 640) | 0x20000300 +2015-09-16 16:57:57,645 - INFO # 3 | pktdump | bl rx _ | 6 | 1536 ( 544) | 0x200025e0 +2015-09-16 16:57:57,647 - INFO # 4 | at86rfxx | bl rx _ | 3 | 1024 ( 360) | 0x2000099c +2015-09-16 16:57:57,649 - INFO # | SUM | | | 4352 ( 1684) +``` + +RIOT specific +============= + +The `ps` command is used to analyze the thread's state and memory +status. + + +Networking +========== + +The `ifconfig` command will help you to configure all available network +interfaces. On an iolab-m3 it will print something like: +``` +2015-09-16 16:58:37,762 - INFO # ifconfig +2015-09-16 16:58:37,766 - INFO # Iface 4 HWaddr: 9e:72 Channel: 26 NID: 0x23 TX-Power: 0dBm State: IDLE CSMA Retries: 4 +2015-09-16 16:58:37,768 - INFO # Long HWaddr: 36:32:48:33:46:da:9e:72 +2015-09-16 16:58:37,769 - INFO # AUTOACK CSMA +2015-09-16 16:58:37,770 - INFO # Source address length: 2 +``` + +Type `ifconfig help` to get an online help for all available options (e.g. +setting the radio channel via `ifconfig 4 set chan 12`). + +The `txtsnd` command allows you to send a simple string directly over the link +layer using unicast or broadcast. The application will also automatically print +information about any received packet over the serial. This will look like: +``` +2015-09-16 16:59:29,187 - INFO # PKTDUMP: data received: +2015-09-16 16:59:29,189 - INFO # ~~ SNIP 0 - size: 28 byte, type: +NETTYPE_UNDEF (0) +2015-09-16 16:59:29,190 - INFO # 000000 7b 3b 3a 02 85 00 e7 fb 00 00 00 00 01 +02 5a 55 +2015-09-16 16:59:29,192 - INFO # 000010 40 42 3e 62 f2 1a 00 00 00 00 00 00 +2015-09-16 16:59:29,194 - INFO # ~~ SNIP 1 - size: 18 byte, type: +NETTYPE_NETIF (-1) +2015-09-16 16:59:29,195 - INFO # if_pid: 4 rssi: 49 lqi: 78 +2015-09-16 16:59:29,196 - INFO # src_l2addr: 5a:55:40:42:3e:62:f2:1a +2015-09-16 16:59:29,197 - INFO # dst_l2addr: ff:ff +2015-09-16 16:59:29,198 - INFO # ~~ PKT - 2 snips, total size: 46 byte +``` diff --git a/tests/lw_mac/main.c b/tests/lw_mac/main.c new file mode 100644 index 000000000000..a9e56d215bcf --- /dev/null +++ b/tests/lw_mac/main.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008, 2009, 2010 Kaspar Schleiser + * Copyright (C) 2013 INRIA + * Copyright (C) 2013 Ludwig Knüpfer + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup examples + * @{ + * + * @file + * @brief Default application that shows a lot of functionality of RIOT + * + * @author Kaspar Schleiser + * @author Oliver Hahm + * @author Ludwig Knüpfer + * + * @} + */ + +#include +#include + +#include "thread.h" +#include "shell.h" +#include "shell_commands.h" + +#if FEATURE_PERIPH_RTC +#include "periph/rtc.h" +#endif + +#ifdef MODULE_LTC4150 +#include "ltc4150.h" +#endif + +#ifdef MODULE_NETIF +#include "net/gnrc/pktdump.h" +#include "net/gnrc.h" +#endif + +int main(void) +{ +#ifdef MODULE_LTC4150 + ltc4150_start(); +#endif + +#ifdef FEATURE_PERIPH_RTC + rtc_init(); +#endif + +#ifdef MODULE_NETIF + gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL, + gnrc_pktdump_pid); + gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump); +#endif + + (void) puts("Welcome to RIOT!"); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + + return 0; +}