Skip to content

Commit 24570d5

Browse files
committed
tests: Added test for the cc110x driver
1 parent cdc6016 commit 24570d5

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

tests/driver_cc110x/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
BOARD ?= msba2
2+
include ../Makefile.tests_common
3+
4+
DEVICE ?= cc1100 # The MSB-A2 uses the CC1100. New boards use CC1101
5+
6+
# This test will rely on a human interacting with the shell, so we better add
7+
# the shell and some commands
8+
USEMODULE += shell
9+
USEMODULE += shell_commands
10+
# Add the device driver
11+
USEMODULE += $(DEVICE)
12+
# Add a network stack and auto init of the network devices
13+
USEMODULE += gnrc
14+
USEMODULE += auto_init_gnrc_netif
15+
USEMODULE += gnrc_ipv6_router_default
16+
# checking current state of network threads can be useful for testing/debuggig
17+
USEMODULE += ps
18+
# txtsnd can be useful to test lower layers
19+
USEMODULE += gnrc_txtsnd
20+
USEMODULE += auto_init_gnrc_netif
21+
# Activate ICMPv6 error messages
22+
USEMODULE += gnrc_icmpv6_error
23+
# This application dumps received packets to STDIO using the pktdump module
24+
USEMODULE += gnrc_pktdump
25+
# Additional networking modules that can be dropped if not needed
26+
USEMODULE += gnrc_icmpv6_echo
27+
# Some statistics could also be helpful
28+
USEMODULE += netstats_l2
29+
USEMODULE += netstats_ipv6
30+
31+
include $(RIOTBASE)/Makefile.include

tests/driver_cc110x/main.c

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser
5+
* General Public License v2.1. See the file LICENSE in the top level
6+
* directory for more details.
7+
*/
8+
9+
/**
10+
* @ingroup tests
11+
* @{
12+
*
13+
* @file
14+
* @brief Test application for the CC110x driver
15+
*
16+
* @author Marian Buschsieweke <[email protected]>
17+
*
18+
* @}
19+
*/
20+
21+
#include <stdio.h>
22+
#include <string.h>
23+
24+
#include "shell.h"
25+
#include "shell_commands.h"
26+
27+
#include "net/gnrc/pktdump.h"
28+
#include "net/gnrc.h"
29+
30+
#define MAIN_QUEUE_SIZE (8)
31+
32+
static int sc_dump(int argc, char **argv);
33+
34+
static const shell_command_t shell_commands[] = {
35+
{ "dump", "Enable/disable dumping of frames", sc_dump },
36+
{ NULL, NULL, NULL }
37+
};
38+
39+
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
40+
static gnrc_netreg_entry_t dump;
41+
42+
static int sc_dump(int argc, char **argv)
43+
{
44+
static int is_enabled = 0;
45+
if (argc == 1) {
46+
if (is_enabled) {
47+
puts("Currently dumping packets");
48+
}
49+
else {
50+
puts("Currently NOT dumping packets");
51+
}
52+
return 0;
53+
}
54+
else if (argc == 2) {
55+
int new_state = 0;
56+
if (!strcmp("y", argv[1])) {
57+
new_state = 1;
58+
}
59+
else if (!strcmp("n", argv[1])) {
60+
new_state = 0;
61+
}
62+
else {
63+
printf("Usage: %s [y/n]\n", argv[0]);
64+
return 0;
65+
}
66+
if (new_state == is_enabled) {
67+
// Nothing to do;
68+
return 0;
69+
}
70+
71+
if (new_state) {
72+
if (gnrc_netreg_register(GNRC_NETTYPE_SIXLOWPAN, &dump)) {
73+
puts("Failed to register packet dumping");
74+
}
75+
}
76+
else {
77+
gnrc_netreg_unregister(GNRC_NETTYPE_SIXLOWPAN, &dump);
78+
}
79+
80+
is_enabled = new_state;
81+
return 0;
82+
}
83+
84+
printf("Usage: %s [y/n]\n", argv[0]);
85+
return 0;
86+
}
87+
88+
int main(void)
89+
{
90+
/* we need a message queue for the thread running the shell in order to
91+
* receive potentially fast incoming networking packets */
92+
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
93+
94+
gnrc_netreg_entry_init_pid(&dump, GNRC_NETREG_DEMUX_CTX_ALL,
95+
gnrc_pktdump_pid);
96+
97+
puts("cc110x driver test application\n"
98+
"==============================\n"
99+
"\n"
100+
"Use the shell and two boards equipped with an CC1100/CC1101\n"
101+
"transceiver to test the driver. Common testing tasks:\n"
102+
"\n"
103+
"- Using \"ifconfig\":\n"
104+
" - Check the information stated for plausibility/correctness\n"
105+
" - Try to get/set parameters like TX power, channel, address, ...\n"
106+
" - BEWARE: With short communication distances (<=1m) for boards\n"
107+
" with high gain antennas a high TX power may result in packet\n"
108+
" loss: The incoming signal can only be demodulated when the\n"
109+
" input signal is at most +10 dBm on the CC1101.\n"
110+
" - Check the statistics for correctness/plausibility (after\n"
111+
" sending frames using \"txtsnd\" or \"ping6\")\n"
112+
"- Using \"ping6\":\n"
113+
" - Does the other device respond to the ping?\n"
114+
" - Does the measured RSSI increase when the nodes are closer\n"
115+
" together?\n"
116+
" - Try to increase the size of the pings, so that the TX/RX FIFO\n"
117+
" needs to be filled/drain more than once per frame. The TX/RX\n"
118+
" FIFO can hold 64 bytes\n"
119+
" - Try to increase the size of the pings in order to trigger L2\n"
120+
" fragmentation. The driver supports frames of up to 255 bytes\n"
121+
"- Using \"txtsnd\":\n"
122+
" - Turn on packet dumping using the command \"dump y\" on node A\n"
123+
" - Send both unicast and broadcast frame from node B to A\n");
124+
char line_buf[SHELL_DEFAULT_BUFSIZE];
125+
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
126+
127+
return 0;
128+
}

0 commit comments

Comments
 (0)