Skip to content

Instantly share code, notes, and snippets.

@kaspar030
Created January 28, 2019 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaspar030/75a737968f861a9ec19dce7b4bc33bf0 to your computer and use it in GitHub Desktop.
Save kaspar030/75a737968f861a9ec19dce7b4bc33bf0 to your computer and use it in GitHub Desktop.
diff --git a/core/msg.c b/core/msg.c
index a46875f16e..1c9886d718 100644
--- a/core/msg.c
+++ b/core/msg.c
@@ -33,7 +33,7 @@
#include "irq.h"
#include "cib.h"
-#define ENABLE_DEBUG (0)
+#define ENABLE_DEBUG (1)
#include "debug.h"
static int _msg_receive(msg_t *m, int block);
@@ -162,6 +162,7 @@ static int _msg_send(msg_t *m, kernel_pid_t target_pid, bool block, unsigned sta
/* copy msg to target */
msg_t *target_message = (msg_t*) target->wait_data;
*target_message = *m;
+
sched_set_status(target, STATUS_PENDING);
irq_restore(state);
@@ -212,7 +213,7 @@ int msg_send_int(msg_t *m, kernel_pid_t target_pid)
return 1;
}
else {
- DEBUG("msg_send_int: Receiver not waiting.\n");
+ DEBUG("msg_send_int: Receiver pid=%" PRIkernel_pid " not waiting.\n", target_pid);
return (queue_msg(target, m));
}
}
@@ -289,6 +290,8 @@ int msg_receive(msg_t *m)
static int _msg_receive(msg_t *m, int block)
{
unsigned state = irq_disable();
+ volatile msg_t *_m = (volatile msg_t *)m;
+ _m->content.value = 0x87654321;
DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive.\n",
sched_active_thread->pid);
@@ -329,13 +332,17 @@ static int _msg_receive(msg_t *m, int block)
irq_restore(state);
thread_yield_higher();
+ if (_m->content.value == 0x87654321) {
+ DEBUG("_msg_receive(): %" PRIkernel_pid ": BUG\n", sched_active_thread->pid);
+ assert(false);
+ }
/* sender copied message */
+ return 1;
}
else {
irq_restore(state);
+ return 2;
}
-
- return 1;
}
else {
DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive(): Waking up waiting thread.\n",
@@ -366,7 +373,7 @@ static int _msg_receive(msg_t *m, int block)
if (sender_prio < THREAD_PRIORITY_IDLE) {
sched_switch(sender_prio);
}
- return 1;
+ return 3;
}
DEBUG("This should have never been reached!\n");
diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
index feb2e8f10f..a62887c250 100644
--- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
+++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
@@ -180,7 +180,8 @@ static void *_event_loop(void *args)
/* start event loop */
while (1) {
DEBUG("ipv6: waiting for incoming message.\n");
- msg_receive(&msg);
+ memset(&msg, 0, sizeof(msg));
+ int res = msg_receive(&msg);
switch (msg.type) {
case GNRC_NETAPI_MSG_TYPE_RCV:
@@ -220,6 +221,7 @@ static void *_event_loop(void *args)
gnrc_ipv6_nib_handle_timer_event(msg.content.ptr, msg.type);
break;
default:
+ printf("ipv6: unknown message type 0x%04x, res=%i\n", msg.type, res);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment