From 7943751b16f91de2871edaa561801fa2d480f521 Mon Sep 17 00:00:00 2001 From: kkrentz Date: Wed, 5 Jun 2013 06:26:54 -0700 Subject: [PATCH] Sky: DEBUG on/off switch --- platform/sky/contiki-sky-main.c | 51 +++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/platform/sky/contiki-sky-main.c b/platform/sky/contiki-sky-main.c index f572209c3..639d0d108 100644 --- a/platform/sky/contiki-sky-main.c +++ b/platform/sky/contiki-sky-main.c @@ -97,6 +97,13 @@ static uint8_t is_gateway; #include "experiment-setup.h" #endif +#define DEBUG 1 +#if DEBUG +#define PRINTF(...) printf(__VA_ARGS__) +#else /* DEBUG */ +#define PRINTF(...) +#endif /* DEBUG */ + void init_platform(void); /*---------------------------------------------------------------------------*/ @@ -144,11 +151,11 @@ set_rime_addr(void) } #endif linkaddr_set_node_addr(&addr); - printf("Rime started with address "); + PRINTF("Rime started with address "); for(i = 0; i < sizeof(addr.u8) - 1; i++) { - printf("%d.", addr.u8[i]); + PRINTF("%d.", addr.u8[i]); } - printf("%d\n", addr.u8[i]); + PRINTF("%d\n", addr.u8[i]); } /*---------------------------------------------------------------------------*/ #if !PROCESS_CONF_NO_PROCESS_NAMES @@ -171,9 +178,9 @@ set_gateway(void) { if(!is_gateway) { leds_on(LEDS_RED); - printf("%d.%d: making myself the IP network gateway.\n\n", + PRINTF("%d.%d: making myself the IP network gateway.\n\n", linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]); - printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n", + PRINTF("IPv4 address of the gateway: %d.%d.%d.%d\n\n", uip_ipaddr_to_quad(&uip_hostaddr)); uip_over_mesh_set_gateway(&linkaddr_node_addr); uip_over_mesh_make_announced_gateway(); @@ -187,8 +194,6 @@ start_autostart_processes() { #if !PROCESS_CONF_NO_PROCESS_NAMES print_processes(autostart_processes); -#else /* !PROCESS_CONF_NO_PROCESS_NAMES */ - putchar('\n'); /* include putchar() */ #endif /* !PROCESS_CONF_NO_PROCESS_NAMES */ autostart_start(autostart_processes); } @@ -201,17 +206,19 @@ start_uip6() process_start(&tcpip_process, NULL); - printf("Tentative link-local IPv6 address "); +#if DEBUG + PRINTF("Tentative link-local IPv6 address "); { uip_ds6_addr_t *lladdr; int i; lladdr = uip_ds6_get_link_local(-1); for(i = 0; i < 7; ++i) { - printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], + PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]); } - printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); + PRINTF("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); } +#endif /* DEBUG */ if(!UIP_CONF_IPV6_RPL) { uip_ipaddr_t ipaddr; @@ -219,12 +226,12 @@ start_uip6() uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); - printf("Tentative global IPv6 address "); + PRINTF("Tentative global IPv6 address "); for(i = 0; i < 7; ++i) { - printf("%02x%02x:", + PRINTF("%02x%02x:", ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); } - printf("%02x%02x\n", + PRINTF("%02x%02x\n", ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); } } @@ -321,21 +328,21 @@ main(int argc, char **argv) linkaddr_node_addr.u8[1]; memset(longaddr, 0, sizeof(longaddr)); linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr); - printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", + PRINTF("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", longaddr[0], longaddr[1], longaddr[2], longaddr[3], longaddr[4], longaddr[5], longaddr[6], longaddr[7]); cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr); } - printf(CONTIKI_VERSION_STRING " started. "); + PRINTF(CONTIKI_VERSION_STRING " started. "); if(node_id > 0) { - printf("Node id is set to %u.\n", node_id); + PRINTF("Node id is set to %u.\n", node_id); } else { - printf("Node id is not set.\n"); + PRINTF("Node id is not set.\n"); } - /* printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + /* PRINTF("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", ds2411_id[0], ds2411_id[1], ds2411_id[2], ds2411_id[3], ds2411_id[4], ds2411_id[5], ds2411_id[6], ds2411_id[7]);*/ @@ -343,14 +350,14 @@ main(int argc, char **argv) memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr)); /* Setup nullmac-like MAC for 802.15.4 */ /* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */ -/* printf(" %s channel %u\n", sicslowmac_driver.name, CC2420_CONF_CCA_THRESH); */ +/* PRINTF(" %s channel %u\n", sicslowmac_driver.name, CC2420_CONF_CCA_THRESH); */ /* Setup X-MAC for 802.15.4 */ queuebuf_init(); NETSTACK_RDC.init(); NETSTACK_MAC.init(); - printf("%s %s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n", + PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n", NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name, CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: NETSTACK_RDC.channel_check_interval()), @@ -363,7 +370,7 @@ main(int argc, char **argv) NETSTACK_MAC.init(); NETSTACK_NETWORK.init(); - printf("%s %s %s, channel check rate %lu Hz, radio channel %u\n", + PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u\n", NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name, CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1: NETSTACK_RDC.channel_check_interval()), @@ -406,7 +413,7 @@ main(int argc, char **argv) uip_over_mesh_set_gateway_netif(&slipif); uip_fw_default(&meshif); uip_over_mesh_init(UIP_OVER_MESH_CHANNEL); - printf("uIP started with IP address %d.%d.%d.%d\n", + PRINTF("uIP started with IP address %d.%d.%d.%d\n", uip_ipaddr_to_quad(&hostaddr)); } #endif /* WITH_UIP */