Add PRINTA so direct calls to debug routines will always print

This commit is contained in:
dak664 2011-03-13 11:57:39 -04:00
parent b7baf22a02
commit a883c9bcbc
2 changed files with 16 additions and 12 deletions

View file

@ -26,7 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uip-debug.c,v 1.1 2010/04/30 13:20:57 joxe Exp $
*/
/**
@ -39,7 +38,7 @@
*/
#include "net/uip-debug.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
void
uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
@ -52,19 +51,19 @@ uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
a = (addr->u8[i] << 8) + addr->u8[i + 1];
if(a == 0 && f >= 0) {
if(f++ == 0) {
printf("::");
PRINTA("::");
}
} else {
if(f > 0) {
f = -1;
} else if(i > 0) {
printf(":");
PRINTA(":");
}
printf("%x", a);
PRINTA("%x", a);
}
}
#else /* UIP_CONF_IPV6 */
printf("%u.%u.%u.%u", addr->u8[0], addr->u8[1], addr->u8[2], addr->u8[3]);
PRINTA("%u.%u.%u.%u", addr->u8[0], addr->u8[1], addr->u8[2], addr->u8[3]);
#endif /* UIP_CONF_IPV6 */
}
/*---------------------------------------------------------------------------*/
@ -74,9 +73,9 @@ uip_debug_lladdr_print(const uip_lladdr_t *addr)
unsigned int i;
for(i = 0; i < sizeof(uip_lladdr_t); i++) {
if(i > 0) {
printf(":");
PRINTA(":");
}
printf("%02x", addr->addr[i]);
PRINTA("%02x", addr->addr[i]);
}
}
/*---------------------------------------------------------------------------*/

View file

@ -43,6 +43,7 @@
#define UIP_DEBUG_H
#include "net/uip.h"
#include <stdio.h>
void uip_debug_ipaddr_print(const uip_ipaddr_t *addr);
void uip_debug_lladdr_print(const uip_lladdr_t *addr);
@ -52,10 +53,16 @@ void uip_debug_lladdr_print(const uip_lladdr_t *addr);
#define DEBUG_ANNOTATE 2
#define DEBUG_FULL DEBUG_ANNOTATE | DEBUG_PRINT
#if (DEBUG) & DEBUG_ANNOTATE
#include <stdio.h>
/* PRINTA will always print if the debug routines are called directly */
#ifdef __AVR__
#include <avr/pgmspace.h>
#define PRINTA(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define PRINTA(...) printf(__VA_ARGS__)
#endif
#if (DEBUG) & DEBUG_ANNOTATE
#ifdef __AVR__
#define ANNOTATE(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define ANNOTATE(...) printf(__VA_ARGS__)
@ -65,9 +72,7 @@ void uip_debug_lladdr_print(const uip_lladdr_t *addr);
#endif /* (DEBUG) & DEBUG_ANNOTATE */
#if (DEBUG) & DEBUG_PRINT
#include <stdio.h>
#ifdef __AVR__
#include <avr/pgmspace.h>
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define PRINTF(...) printf(__VA_ARGS__)