52 #define LOG_MODULE "Energest" 53 #define LOG_LEVEL LOG_LEVEL_INFO 55 static unsigned long last_tx, last_rx, last_time, last_cpu, last_lpm, last_deep_lpm;
56 static unsigned long delta_tx, delta_rx, delta_time, delta_cpu, delta_lpm, delta_deep_lpm;
57 static unsigned long curr_tx, curr_rx, curr_time, curr_cpu, curr_lpm, curr_deep_lpm;
59 PROCESS(simple_energest_process,
"Simple Energest");
62 to_permil(
unsigned long delta_metric,
unsigned long delta_time)
64 return (1000ul * (delta_metric)) / delta_time;
68 simple_energest_step(
void)
70 static unsigned count = 0;
74 curr_time = ENERGEST_GET_TOTAL_TIME();
75 curr_cpu = energest_type_time(ENERGEST_TYPE_CPU);
76 curr_lpm = energest_type_time(ENERGEST_TYPE_LPM);
77 curr_deep_lpm = energest_type_time(ENERGEST_TYPE_DEEP_LPM);
78 curr_tx = energest_type_time(ENERGEST_TYPE_TRANSMIT);
79 curr_rx = energest_type_time(ENERGEST_TYPE_LISTEN);
81 delta_time = curr_time - last_time;
82 delta_cpu = curr_cpu - last_cpu;
83 delta_lpm = curr_lpm - last_lpm;
84 delta_deep_lpm = curr_deep_lpm - last_deep_lpm;
85 delta_tx = curr_tx - last_tx;
86 delta_rx = curr_rx - last_rx;
88 last_time = curr_time;
91 last_deep_lpm = curr_deep_lpm;
95 LOG_INFO(
"--- Period summary #%u (%lu seconds)\n", count++, delta_time/ENERGEST_SECOND);
96 LOG_INFO(
"Total time : %10lu\n", delta_time);
97 LOG_INFO(
"CPU : %10lu/%10lu (%lu permil)\n", delta_cpu, delta_time, to_permil(delta_cpu, delta_time));
98 LOG_INFO(
"LPM : %10lu/%10lu (%lu permil)\n", delta_lpm, delta_time, to_permil(delta_lpm, delta_time));
99 LOG_INFO(
"Deep LPM : %10lu/%10lu (%lu permil)\n", delta_deep_lpm, delta_time, to_permil(delta_deep_lpm, delta_time));
100 LOG_INFO(
"Radio Tx : %10lu/%10lu (%lu permil)\n", delta_tx, delta_time, to_permil(delta_tx, delta_time));
101 LOG_INFO(
"Radio Rx : %10lu/%10lu (%lu permil)\n", delta_rx, delta_time, to_permil(delta_rx, delta_time));
102 LOG_INFO(
"Radio total : %10lu/%10lu (%lu permil)\n", delta_tx+delta_rx, delta_time, to_permil(delta_tx+delta_rx, delta_time));
107 static struct etimer periodic_timer;
114 simple_energest_step();
123 last_time = ENERGEST_GET_TOTAL_TIME();
124 last_cpu = energest_type_time(ENERGEST_TYPE_CPU);
125 last_lpm = energest_type_time(ENERGEST_TYPE_LPM);
126 curr_tx = energest_type_time(ENERGEST_TYPE_TRANSMIT);
127 last_deep_lpm = energest_type_time(ENERGEST_TYPE_DEEP_LPM);
128 last_rx = energest_type_time(ENERGEST_TYPE_LISTEN);
#define PROCESS(name, strname)
Declare a process.
Header file for the energy estimation mechanism
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_END()
Define the end of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
A process that periodically prints out the time spent in radio tx, radio rx, total time and duty cycle.
void simple_energest_init(void)
Initialize the deployment module.
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
#define SIMPLE_ENERGEST_PERIOD
The period at which Energest statistics will be logged.
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
Header file for the logging system
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
void process_start(struct process *p, process_data_t data)
Start a process.