Skip to content

Conversation

@miri64
Copy link
Contributor

@miri64 miri64 commented Dec 23, 2013

Tests for RIOT-OS/RIOT#460

@miri64
Copy link
Contributor Author

miri64 commented Dec 23, 2013

@LudwigOrtmann net_if_send_packet() returns everything as expected, but wireshark does not return anything on native. Did I miss something?

@LudwigKnuepfer
Copy link
Contributor

Ill check.

@LudwigKnuepfer
Copy link
Contributor

I don't pretend to understand what's really going on, but it appears you don't initialize and start the transceiver transceiver_init(transceivers), transceiver_start()).

@LudwigKnuepfer
Copy link
Contributor

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;

@LudwigKnuepfer
Copy link
Contributor

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");

@LudwigKnuepfer
Copy link
Contributor

It appears there is some integer problem as it says: Count was 134572496 after net_if_send_packet()

@miri64
Copy link
Contributor Author

miri64 commented Dec 24, 2013

@LudwigOrtmann thanks -.- I specified it myself that the module has to initialize the transceiver first and who forgot it.... me myself and I facepalm

@miri64
Copy link
Contributor Author

miri64 commented Dec 24, 2013

Okay fixed everything and now it runs. But (unrelated to this PR): nativenet_send() returns 60 for some reason, though it's documentation states it either returns 0 or -1.

@LudwigKnuepfer
Copy link
Contributor

nativenet_send() returns 60 for some reason, though it's documentation states it either returns 0 or -1

Hehe, I updated the return value to be in line with the remaining modules but forgot to update the documentation ...

@LudwigKnuepfer
Copy link
Contributor

RIOT-OS/RIOT#472

@miri64
Copy link
Contributor Author

miri64 commented Dec 24, 2013

👍 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 :/

@LudwigKnuepfer
Copy link
Contributor

The transceivers don't necessarily return the payload size... at least cc110x_ng and native don't.

@LudwigKnuepfer
Copy link
Contributor

Also, while you're at it - why don't you add tests for corner cases? 0, max_payload_size, ...

@miri64
Copy link
Contributor Author

miri64 commented Dec 24, 2013

kk is max_payload_size a variable defined by the transceiver?

@LudwigKnuepfer
Copy link
Contributor

The name is PAYLOAD_SIZE.

@LudwigKnuepfer
Copy link
Contributor

@LudwigKnuepfer
Copy link
Contributor

Will you move this to RIOT?

@miri64
Copy link
Contributor Author

miri64 commented Jan 21, 2014

@LudwigOrtmann yep. Already done it: RIOT-OS/RIOT#460

@miri64 miri64 closed this Jan 21, 2014
@miri64 miri64 deleted the test_net_if branch February 6, 2014 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants