1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #834 from OlegHahm/debug_addon

Debug addon
This commit is contained in:
Oleg Hahm 2014-03-20 09:40:33 +01:00
commit ce812842a5
4 changed files with 36 additions and 3 deletions

View File

@ -23,12 +23,37 @@
#define __DEBUG_H #define __DEBUG_H
#include <stdio.h> #include <stdio.h>
#include "sched.h"
#if DEVELHELP
#include "cpu-conf.h"
#define DEBUG_PRINT(...) \
do { \
if ((active_thread == NULL) || (active_thread->stack_size > KERNEL_CONF_STACKSIZE_PRINTF)) { \
printf(__VA_ARGS__); \
} \
else { \
puts("Cannot debug, stack too small"); \
} \
} while (0)
#else
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#endif
#if ENABLE_DEBUG #if ENABLE_DEBUG
#define DEBUG(...) printf(__VA_ARGS__) #include "tcb.h"
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
#define DEBUGF(...) \
do { \
DEBUG_PRINT("DEBUG(%s): %s:%d in %s: ", \
active_thread ? active_thread->name : "NO THREAD", \
__FILE__, __LINE__, __func__); \
DEBUG_PRINT(__VA_ARGS__); \
} while (0)
#undef ENABLE_DEBUG #undef ENABLE_DEBUG
#else #else
#define DEBUG(...) #define DEBUG(...)
#define DEBUGF(...)
#endif #endif
/** @} */ /** @} */

View File

@ -29,6 +29,7 @@
#include "thread.h" #include "thread.h"
#include "irq.h" #include "irq.h"
#define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
int mutex_init(struct mutex_t *mutex) int mutex_init(struct mutex_t *mutex)

View File

@ -29,7 +29,7 @@
#include "demo.h" #include "demo.h"
#define ENABLE_DEBUG (1) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
#define LL_HDR_LEN (0x4) #define LL_HDR_LEN (0x4)
@ -69,7 +69,7 @@ void rpl_udp_monitor(void)
if (m.type == PKT_PENDING) { if (m.type == PKT_PENDING) {
p = (radio_packet_t *) m.content.ptr; p = (radio_packet_t *) m.content.ptr;
DEBUG("Received packet from ID %u\n", p->src); DEBUGF("Received packet from ID %u\n", p->src);
DEBUG("\tLength:\t%u\n", p->length); DEBUG("\tLength:\t%u\n", p->length);
DEBUG("\tSrc:\t%u\n", p->src); DEBUG("\tSrc:\t%u\n", p->src);
DEBUG("\tDst:\t%u\n", p->dst); DEBUG("\tDst:\t%u\n", p->dst);

View File

@ -29,6 +29,9 @@
#include "rpl_dodag.h" #include "rpl_dodag.h"
#include "demo.h" #include "demo.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
#define TRANSCEIVER TRANSCEIVER_NATIVE #define TRANSCEIVER TRANSCEIVER_NATIVE
#else #else
@ -65,8 +68,10 @@ void rpl_udp_init(int argc, char **argv)
return; return;
} }
DEBUGF("Setting HW address to %u\n", id);
net_if_set_hardware_address(0, id); net_if_set_hardware_address(0, id);
DEBUGF("Initializing RPL for interface 0\n");
state = rpl_init(0); state = rpl_init(0);
if (state != SIXLOWERROR_SUCCESS) { if (state != SIXLOWERROR_SUCCESS) {
@ -84,7 +89,9 @@ void rpl_udp_init(int argc, char **argv)
ipv6_iface_set_routing_provider(rpl_get_next_hop); ipv6_iface_set_routing_provider(rpl_get_next_hop);
} }
DEBUGF("Start monitor\n");
int monitor_pid = thread_create(monitor_stack_buffer, MONITOR_STACK_SIZE, PRIORITY_MAIN - 2, CREATE_STACKTEST, rpl_udp_monitor, "monitor"); int monitor_pid = thread_create(monitor_stack_buffer, MONITOR_STACK_SIZE, PRIORITY_MAIN - 2, CREATE_STACKTEST, rpl_udp_monitor, "monitor");
DEBUGF("Register at transceiver %02X\n", TRANSCEIVER);
transceiver_register(TRANSCEIVER, monitor_pid); transceiver_register(TRANSCEIVER, monitor_pid);
ipv6_register_packet_handler(monitor_pid); ipv6_register_packet_handler(monitor_pid);
//sixlowpan_lowpan_register(monitor_pid); //sixlowpan_lowpan_register(monitor_pid);