-
Notifications
You must be signed in to change notification settings - Fork 18
Add test project for module net_if #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@LudwigOrtmann net_if_send_packet() returns everything as expected, but wireshark does not return anything on native. Did I miss something? |
|
Ill check. |
|
I don't pretend to understand what's really going on, but it appears you don't initialize and start the transceiver |
|
BTW: I changed this while looking into it: index 473270f..530480f 100644
--- a/sys/net/link_layer/net_if/net_if.c
+++ b/sys/net/link_layer/net_if/net_if.c
@@ -14,12 +14,17 @@ n* Public License. See the file LICENSE in the top level directory for more
#include <string.h>
#include "clist.h"
-#include "debug.h"
#include "net_if.h"
#include "mutex.h"
#include "transceiver.h"
-#define ENABLE_DEBUG (0)
+#define ENABLE_DEBUG (1)
+#if ENABLE_DEBUG
+#define DEBUG_ENABLED (1)
+#else
+#define DEBUG_ENABLED (0)
+#endif
+#include "debug.h"
#ifndef NET_IF_MAX
/**
@@ -55,14 +60,14 @@ typedef struct __attribute__((packed))
*/
net_if_t interfaces[NET_IF_MAX];
-#if ENABLE_DEBUG
+#if DEBUG_ENABLED
void print_addr_hex(net_if_addr_t *addr)
{
int i;
DEBUG("0x");
for (i = 0; i < addr->addr_len; i++) {
- DEBUG("%02x", (char)addr->addr_data[i]);
+ DEBUG("%02x", ((char*)addr->addr_data)[i]);
}
DEBUG("\n");
@@ -165,6 +170,7 @@ net_if_addr_t *net_if_iter_addresses(int if_id, net_if_addr_t **addr)
uint32_t net_if_transceiver_get_set_handler(int if_id, uint16_t op_type,
void *data)
{
+ DEBUG("net_if_transceiver_get_set_handler: foo\n");
msg_t msg;
transceiver_command_t tcmd;
@@ -180,6 +186,7 @@ uint32_t net_if_transceiver_get_set_handler(int if_id, uint16_t op_type,
int net_if_send_packet(int if_id, transceiver_addr_t target,
void *payload, size_t payload_len)
{
+ DEBUG("net_if_send_packet: foo\n");
radio_packet_t p;
uint32_t response; |
|
Oh, and: diff --git a/test_net_if/Makefile b/test_net_if/Makefile
index 189bd71..a03b0b0 100644
--- a/test_net_if/Makefile
+++ b/test_net_if/Makefile
@@ -29,8 +29,9 @@ ifeq ($(BOARD),native)
USEMODULE += nativenet
else ifeq ($(BOARD),msba2)
USEMODULE += cc110x_ng
+ INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
endif
-export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTCPU)/$(CPU)/inclu
+export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTCPU)/$(CPU)/inclu
include $(RIOTBASE)/Makefile.include
diff --git a/test_net_if/main.c b/test_net_if/main.c
index fd287e9..1e769f1 100644
--- a/test_net_if/main.c
+++ b/test_net_if/main.c
@@ -111,6 +111,9 @@ int main(void)
if (count == 4) {
printf("Expected count to be 4 after net_if_send_packet()\n");
}
+ else {
+ printf("Count was %i after net_if_send_packet()\n", count);
+ }
printf("All test ran successfully.\n"); |
|
It appears there is some integer problem as it says: |
|
@LudwigOrtmann thanks -.- I specified it myself that the module has to initialize the transceiver first and who forgot it.... me myself and I facepalm |
|
Okay fixed everything and now it runs. But (unrelated to this PR): |
Hehe, I updated the return value to be in line with the remaining modules but forgot to update the documentation ... |
|
👍 now I only have to find a way to generalise the protocol overhead so that for the given example it would only return 4 for all transceivers :/ |
|
The transceivers don't necessarily return the payload size... at least cc110x_ng and native don't. |
|
Also, while you're at it - why don't you add tests for corner cases? 0, max_payload_size, ... |
|
kk is max_payload_size a variable defined by the transceiver? |
|
The name is |
|
Will you move this to RIOT? |
|
@LudwigOrtmann yep. Already done it: RIOT-OS/RIOT#460 |
Tests for RIOT-OS/RIOT#460