-
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 test application for slip
- Loading branch information
Showing
2 changed files
with
120 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,18 @@ | ||
APPLICATION = driver_tapnet | ||
include ../Makefile.tests_common | ||
|
||
FEATURES_REQUIRED = periph_uart | ||
|
||
RD_INSUFFICIENT_RAM := stm32f0discovery | ||
|
||
# other boards are missing second UART | ||
BOARD_WHITELIST := arduino-due mbed_lpc1768 msbiot nucleo-f091 \ | ||
stm32f0discovery stm32f3discovery stm32f4discovery udoo | ||
|
||
USEMODULE += ng_netbase | ||
USEMODULE += ng_pktdump | ||
USEMODULE += ng_slip | ||
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,102 @@ | ||
/* | ||
* Copyright (C) 2015 Martine Lenders <[email protected]> | ||
* | ||
* 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 ng_tapnet network device driver | ||
* | ||
* @author Martine Lenders <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "board.h" | ||
#include "kernel.h" | ||
#include "ringbuffer.h" | ||
#include "shell.h" | ||
#include "shell_commands.h" | ||
#include "periph/uart.h" | ||
#include "net/ng_netbase.h" | ||
#include "net/ng_slip.h" | ||
#include "net/ng_pktdump.h" | ||
|
||
/** | ||
* @brief Buffer size used by the shell | ||
*/ | ||
#define SHELL_BUFSIZE (64U) | ||
|
||
/** | ||
* @brief Buffer size for UARTs | ||
*/ | ||
#define UART_BUFSIZE (64U) | ||
|
||
char in_buf_array[UART_BUFSIZE], out_buf_array[UART_BUFSIZE]; | ||
ringbuffer_t in_buf = RINGBUFFER_INIT(in_buf_array); | ||
ringbuffer_t out_buf = RINGBUFFER_INIT(out_buf_array); | ||
ng_slip_dev_t dev = { UART_1, &in_buf, &out_buf, 0, 0, KERNEL_PID_UNDEF }; | ||
|
||
/** | ||
* @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("slip device driver test"); | ||
printf("Initializing tapnet... \n"); | ||
|
||
/* 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); | ||
|
||
res = ng_slip_init(PRIORITY_MAIN - 1, &dev, 115200); | ||
|
||
if (res < 0) { | ||
puts("Error starting slip thread"); | ||
return -1; | ||
} | ||
|
||
/* start the shell */ | ||
shell_init(&shell, NULL, SHELL_BUFSIZE, shell_read, shell_put); | ||
shell_run(&shell); | ||
|
||
return 0; | ||
} |