-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add manual test application for netdev_eth
- Loading branch information
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
APPLICATION = driver_netdev_eth | ||
include ../Makefile.tests_common | ||
|
||
BOARD_WHITELIST := native | ||
|
||
USEMODULE += ng_nativenet | ||
USEMODULE += ng_netbase | ||
USEMODULE += ng_nomac | ||
USEMODULE += ng_pktdump | ||
USEMODULE += ng_netdev_eth | ||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de> | ||
* 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 tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Test application for netdev ethernet device driver | ||
* | ||
* @author Martine Lenders <mlenders@inf.fu-berlin.de> | ||
* Kaspar Schleiser <kaspar@schleiser.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "board.h" | ||
#include "kernel.h" | ||
#include "shell.h" | ||
#include "shell_commands.h" | ||
#include "net/ng_netbase.h" | ||
#include "net/ng_nomac.h" | ||
#include "net/ng_pktdump.h" | ||
#include "net/ng_netdev_eth.h" | ||
#include "net/dev_eth.h" | ||
#include "dev_eth_tap.h" | ||
|
||
/** | ||
* @brief Buffer size used by the shell | ||
*/ | ||
#define SHELL_BUFSIZE (64U) | ||
|
||
/** | ||
* @brief Stack for the nomac thread | ||
*/ | ||
static char nomac_stack[KERNEL_CONF_STACKSIZE_DEFAULT]; | ||
|
||
/** | ||
* @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) | ||
{ | ||
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; | ||
|
||
if (dump.pid <= KERNEL_PID_UNDEF) { | ||
puts("Error starting pktdump thread"); | ||
return -1; | ||
} | ||
|
||
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), 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); | ||
|
||
return 0; | ||
} |