1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

Merge pull request #3096 from OlegHahm/ng_nativenet_netdev_auto_foobar

ng_nativenet: auto initialization and improvements
This commit is contained in:
Martine Lenders 2015-06-03 17:53:18 +02:00
commit 5e7de0821b
10 changed files with 80 additions and 24 deletions

View File

@ -1,6 +1,9 @@
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
USEMODULE += nativenet
ifeq (,$(filter netdev_base,$(USEMODULE)))
ifeq (,$(filter ng_netif,$(USEMODULE)))
USEMODULE += nativenet
USEMODULE += transceiver
else
USEMODULE += ng_nativenet
USEMODULE += ng_netdev_eth
endif
endif

View File

@ -68,7 +68,7 @@ export LINKFLAGS += -ldl
endif
# set the tap interface for term/valgrind
ifneq (,$(filter nativenet,$(USEMODULE)))
ifneq (,$(filter %nativenet,$(USEMODULE)))
export PORT ?= tap0
else
export PORT =

View File

@ -335,6 +335,11 @@ void auto_init(void)
auto_init_kw2xrf();
#endif
#ifdef MODULE_NG_NETDEV_ETH
extern void auto_init_ng_netdev_eth(void);
auto_init_ng_netdev_eth();
#endif
#endif /* MODULE_AUTO_INIT_NG_NETIF */
#ifdef MODULE_NG_IPV6_NETIF

View File

@ -65,6 +65,8 @@ void auto_init_kw2xrf(void)
}
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_NG_KW2XRF */
/** @} */

View File

@ -64,6 +64,8 @@ void auto_init_ng_at86rf2xx(void)
}
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_NG_AT86RF2XX */
/** @} */

View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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 auto_init_ng_netif
* @{
*
* @file
* @brief Auto initialization for netdev Ethernet network interfaces
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#ifdef MODULE_NG_NETDEV_ETH
#include "board.h"
#include "net/ng_nomac.h"
#include "net/ng_netbase.h"
#include "net/ng_netdev_eth.h"
#include "net/dev_eth.h"
#include "dev_eth_tap.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
/**
* @brief Define stack parameters for the MAC layer thread
* @{
*/
#define NETDEV_ETH_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#define NETDEV_ETH_MAC_PRIO (THREAD_PRIORITY_MAIN - 3)
static char _nomac_stack[NETDEV_ETH_MAC_STACKSIZE];
void auto_init_ng_netdev_eth(void)
{
DEBUG("Initializing NETDEV_ETH device\n");
int res = ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);
if (res < 0) {
DEBUG("Error initializing NETDEV_ETH device!");
}
else {
ng_nomac_init(_nomac_stack, NETDEV_ETH_MAC_STACKSIZE, NETDEV_ETH_MAC_PRIO,
"tapnet", (ng_netdev_t *)&ng_netdev_eth);
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_NG_NETDEV_ETH */
/** @} */

View File

@ -60,5 +60,7 @@ void auto_init_slip(void)
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_NG_SLIP */
/** @} */

View File

@ -67,5 +67,7 @@ void auto_init_xbee(void)
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_XBEE */
/** @} */

View File

@ -8,6 +8,7 @@ USEMODULE += ng_netbase
USEMODULE += ng_nomac
USEMODULE += ng_pktdump
USEMODULE += ng_netdev_eth
USEMODULE += auto_init_ng_netif
USEMODULE += shell
USEMODULE += shell_commands

View File

@ -38,11 +38,6 @@
*/
#define SHELL_BUFSIZE (64U)
/**
* @brief Stack for the nomac thread
*/
static char nomac_stack[THREAD_STACKSIZE_DEFAULT];
/**
* @brief Read chars from STDIO
*/
@ -64,15 +59,11 @@ void shell_put(int c)
*/
int main(void)
{
int res;
shell_t shell;
ng_netreg_entry_t dump;
puts("netdev ethernet device driver test");
/* initialize network module(s) */
ng_netif_init();
/* initialize and register pktdump */
dump.pid = ng_pktdump_init();
dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
@ -84,18 +75,6 @@ int main(void)
ng_netreg_register(NG_NETTYPE_UNDEF, &dump);
/* initialize netdev_eth layer */
ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);
/* start MAC layer */
res = ng_nomac_init(nomac_stack, sizeof(nomac_stack), THREAD_PRIORITY_MAIN - 3,
"tapnet_l2", (ng_netdev_t *)&ng_netdev_eth);
if (res < 0) {
printf("Error starting nomac thread. res=%i\n", res);
return -1;
}
/* start the shell */
shell_init(&shell, NULL, SHELL_BUFSIZE, shell_read, shell_put);
shell_run(&shell);