Added a function powertrace_print() that prints out the current power trace

This commit is contained in:
adamdunkels 2010-03-29 21:49:07 +00:00
parent 315e446584
commit 1241aa34d0
2 changed files with 11 additions and 9 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: powertrace.c,v 1.3 2010/03/19 13:23:31 adamdunkels Exp $ * $Id: powertrace.c,v 1.4 2010/03/29 21:49:07 adamdunkels Exp $
*/ */
/** /**
@ -40,7 +40,6 @@
#include "contiki.h" #include "contiki.h"
#include "sys/compower.h" #include "sys/compower.h"
#include "node-id.h"
#include "powertrace.h" #include "powertrace.h"
#include "net/rime.h" #include "net/rime.h"
@ -48,8 +47,8 @@
PROCESS(powertrace_process, "Periodic power output"); PROCESS(powertrace_process, "Periodic power output");
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void void
print_power(void) powertrace_print(char *str)
{ {
static uint32_t last_cpu, last_lpm, last_transmit, last_listen; static uint32_t last_cpu, last_lpm, last_transmit, last_listen;
static uint32_t last_idle_transmit, last_idle_listen; static uint32_t last_idle_transmit, last_idle_listen;
@ -79,8 +78,9 @@ print_power(void)
time = cpu + lpm; time = cpu + lpm;
printf("%lu P %d %lu %lu %lu %lu %lu %lu %lu (radio %d.%02d%% tx %d.%02d%% listen %d.%02d%%)\n", printf("%s %lu P %d %lu %lu %lu %lu %lu %lu %lu (radio %d.%02d%% tx %d.%02d%% listen %d.%02d%%)\n",
clock_time(), node_id, seqno++, str,
clock_time(), rimeaddr_node_addr.u8[0], seqno++,
cpu, lpm, transmit, listen, idle_transmit, idle_listen, cpu, lpm, transmit, listen, idle_transmit, idle_listen,
(int)((100L * (transmit + listen)) / time), (int)((100L * (transmit + listen)) / time),
(int)((10000L * (transmit + listen) / time) - (100L * (transmit + listen) / time) * 100), (int)((10000L * (transmit + listen) / time) - (100L * (transmit + listen) / time) * 100),
@ -106,7 +106,7 @@ PROCESS_THREAD(powertrace_process, ev, data)
while(1) { while(1) {
PROCESS_WAIT_UNTIL(etimer_expired(&periodic)); PROCESS_WAIT_UNTIL(etimer_expired(&periodic));
etimer_reset(&periodic); etimer_reset(&periodic);
print_power(); powertrace_print("");
} }
PROCESS_END(); PROCESS_END();
@ -138,7 +138,7 @@ sniffprint(char *prefix, int seqno)
printf("%lu %s %d %u %d %d %d.%d %u %u\n", printf("%lu %s %d %u %d %d %d.%d %u %u\n",
clock_time(), clock_time(),
prefix, prefix,
node_id, seqno, rimeaddr_node_addr.u8[0], seqno,
packetbuf_attr(PACKETBUF_ATTR_CHANNEL), packetbuf_attr(PACKETBUF_ATTR_CHANNEL),
packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE), packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE),
esender->u8[0], esender->u8[1], esender->u8[0], esender->u8[1],

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: powertrace.h,v 1.3 2010/03/19 13:23:31 adamdunkels Exp $ * $Id: powertrace.h,v 1.4 2010/03/29 21:49:07 adamdunkels Exp $
*/ */
/** /**
@ -53,4 +53,6 @@ typedef enum {
void powertrace_sniff(powertrace_onoff_t onoff); void powertrace_sniff(powertrace_onoff_t onoff);
void powertrace_print(char *str);
#endif /* POWERTRACE_H */ #endif /* POWERTRACE_H */