From ed2228ff6f5fc9b1dcb1c2ed83443b2222a5e0b7 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 12 Oct 2010 11:42:37 +0000 Subject: [PATCH] Replaced the old sky-alldata command with the new collect-view-data command. Added the new shell powertrace command. Cleaned up. --- examples/sky-shell/Makefile | 122 +-------------------- examples/sky-shell/sky-shell.c | 189 ++------------------------------- 2 files changed, 9 insertions(+), 302 deletions(-) diff --git a/examples/sky-shell/Makefile b/examples/sky-shell/Makefile index 9587ca0c0..f7833e36d 100644 --- a/examples/sky-shell/Makefile +++ b/examples/sky-shell/Makefile @@ -1,125 +1,9 @@ CONTIKI_PROJECT = sky-shell all: $(CONTIKI_PROJECT) -dumptest: - (echo "~K"; \ - echo "killall "; \ - echo "time `date +%s` | null"; \ - echo 'netcmd { repeat 0 10 { randwait 10 echo 0123456789abcdef | blink | send } }'; \ - sleep 2; \ - echo "killall "; \ - sleep 2; \ - echo 'collect | binprint &') | make login - -APPS = serial-shell powertrace +APPS = serial-shell powertrace collect-view CONTIKI = ../.. -%.shell-upload: %.ce - (echo; sleep 4; echo "~K"; sleep 4; \ - echo "dec64 | write $*.ce | null"; sleep 4; \ - ../../tools/base64-encode < $<; sleep 4; \ - echo "read $*.ce | size"; sleep 4) | make login - -%.file-upload: % - (echo; sleep 4; echo "~K"; sleep 4; \ - echo "dec64 | write $* | null"; sleep 4; \ - ../../tools/base64-encode < $<; sleep 4; \ - echo "read $* | size"; sleep 4) | make login - -%.netsend: %.shell-upload - (echo; sleep 4; echo "~K"; sleep 4; \ - echo "netcmd { recvnetfile | write $*.ce | size | send } "; sleep 4; \ - echo "netfile $*.ce"; sleep 4;\ - echo "collect | binprint"; sleep 40) | make login - -%.tgz: %.ihex - mkdir $(basename $<) ; \ - mv $< $(basename $<) ; \ - echo $(basename $<)/$(basename $<).ihex 600 > $(basename $<)/runfile ; \ - tar czf $@ $(basename $<) -broadcast: - echo "echo haha | broadcast" | make login - -xprofile: - (sleep 4; echo "sendtest 56.0 100 20"; sleep 4; echo "xmacprofile"; sleep 10) | make login - -xprofile2: - (sleep 4; sleep 4; echo "xmacprofile"; sleep 10) | make login MOTE=2 - -ping: - echo ping 55.0 | make login - -serrors: - (echo "~K"; echo "var serial_byte_dropped") | make login - -reboot: - (echo "~K"; echo "reboot"; sleep 6) | make login - -test64: - (echo "~K"; echo "dec64 | write file"; sleep 2; \ - ../../tools/base64-encode < symbols.c) | make login - -distfile : - (echo "~K"; echo "netcmd { recvnetfile | write file | size | blink }"; \ - sleep 1; echo "netfile file") | make login - -test642: - (echo "~K"; echo "dec64 | write file | null"; sleep 2; \ - ../../tools/base64-encode < hello-world.c; echo ; echo "read file | size" ) | make login - -test2: - (echo "~K"; echo "write file"; sleep 2; \ - cat hello-world.c) | make login - -upload64: - (echo "~K"; echo "dec64 | write file"; sleep 2; \ - ../../tools/base64-encode < symbols.c) | make login - -netfile: - (echo "~K"; echo "netfile file") | make login - -sendtest: - (echo "~K"; \ - echo "killall "; \ - echo "repeat 10 2 sendtest $(NODE) 2000 64"; \ - sleep 24; \ - echo "repeat 10 2 sendtest $(NODE) 2000 32"; \ - sleep 24; \ - echo "repeat 10 2 sendtest $(NODE) 2000 16"; \ - sleep 24; \ - echo 'energy | powerconv' ) | make login - -setup-sensor: - (echo "~K"; \ - echo "killall "; \ - echo "time `date +%s` | null"; \ - echo 'netcmd { repeat 0 20 { randwait 20 sense | blink | send } }'; \ - sleep 2; \ - echo 'collect | timestamp | blink | write file | binprint &') | make login - -setup-sensor-alldata: - (echo "~K"; \ - echo "killall "; \ - echo "time `date +%s` | null"; \ - echo 'netcmd { repeat 0 20 { randwait 20 sky-alldata | blink | send } }'; \ - sleep 2; \ - echo 'collect | timestamp | blink | write file | binprint &') | make login - -collect-sensor-data: - make login | tee collect-sensor-data - -collect-power: - (echo ; \ - echo 'netcmd { repeat 1000 20 { randwait 20 power | send } }'; \ - sleep 2; \ - echo 'collect | timestamp | hd &') | make login - -collect-energy: - (sleep 4; echo "~K"; \ - echo "killall "; \ - echo "time `date +%s` | null"; \ - echo 'netcmd { repeat 1000 40 { randwait 40 energy | send } }'; \ - sleep 4; \ - echo 'collect | timestamp | write file | hd &') | make login - include $(CONTIKI)/Makefile.include +-include /home/user/nes/testbed-scripts/Makefile.include + diff --git a/examples/sky-shell/sky-shell.c b/examples/sky-shell/sky-shell.c index 2785522c8..b62894f3b 100644 --- a/examples/sky-shell/sky-shell.c +++ b/examples/sky-shell/sky-shell.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: sky-shell.c,v 1.24 2010/10/03 20:16:57 adamdunkels Exp $ + * $Id: sky-shell.c,v 1.25 2010/10/12 11:42:37 adamdunkels Exp $ */ /** @@ -38,26 +38,24 @@ * Adam Dunkels */ -#include "powertrace.h" #include "contiki.h" #include "shell.h" #include "serial-shell.h" +#include "collect-view.h" #include "net/rime/collect-neighbor.h" #include "dev/watchdog.h" #include "net/rime.h" +#include "net/rime/broadcast-announcement.h" #include "dev/cc2420.h" #include "dev/leds.h" #include "dev/light-sensor.h" #include "dev/battery-sensor.h" #include "dev/sht11-sensor.h" -#include "lib/checkpoint.h" - #include "net/rime/timesynch.h" -#include "powertrace.h" #include #include @@ -65,182 +63,10 @@ #include #include -#define DEBUG_SNIFFERS 0 - /*---------------------------------------------------------------------------*/ PROCESS(sky_shell_process, "Sky Contiki shell"); AUTOSTART_PROCESSES(&sky_shell_process); /*---------------------------------------------------------------------------*/ -#if DEBUG_SNIFFERS -static void -input_sniffer(void) -{ - int i; - uint8_t *dataptr; - - printf("x %d ", packetbuf_totlen()); - dataptr = packetbuf_dataptr(); - printf("%02x ", dataptr[0]); - /* if(dataptr[0] == 18) {*/ - for(i = 1; i < packetbuf_totlen(); ++i) { - printf("%02x ", dataptr[i]); - } - /* }*/ - printf("\n"); -} -/*---------------------------------------------------------------------------*/ -static void -output_sniffer(void) -{ - uint8_t *dataptr; - printf("- %d ", packetbuf_totlen()); - dataptr = packetbuf_dataptr(); - printf("%02x\n", dataptr[0]); -} -/*---------------------------------------------------------------------------*/ -RIME_SNIFFER(s, input_sniffer, output_sniffer); -#endif /* DEBUG_SNIFFERS */ -/*---------------------------------------------------------------------------*/ -PROCESS(shell_sky_alldata_process, "sky-alldata"); -SHELL_COMMAND(sky_alldata_command, - "sky-alldata", - "sky-alldata: sensor data, power consumption, network stats", - &shell_sky_alldata_process); -/*---------------------------------------------------------------------------*/ -#define MAX(a, b) ((a) > (b)? (a): (b)) -#define MIN(a, b) ((a) < (b)? (a): (b)) -struct spectrum { - int channel[16]; -}; -#define NUM_SAMPLES 4 -static struct spectrum rssi_samples[NUM_SAMPLES]; -static int -do_rssi(void) -{ - static int sample; - int channel; - - rime_mac->off(0); - - cc2420_on(); - for(channel = 11; channel <= 26; ++channel) { - cc2420_set_channel(channel); - rssi_samples[sample].channel[channel - 11] = cc2420_rssi() + 53; - } - - rime_mac->on(); - - sample = (sample + 1) % NUM_SAMPLES; - - { - int channel, tot; - tot = 0; - for(channel = 0; channel < 16; ++channel) { - int max = -256; - int i; - for(i = 0; i < NUM_SAMPLES; ++i) { - max = MAX(max, rssi_samples[i].channel[channel]); - } - tot += max / 20; - } - return tot; - } -} -/*---------------------------------------------------------------------------*/ -struct sky_alldata_msg { - uint16_t len; - uint16_t clock; - uint16_t timesynch_time; - uint16_t light1; - uint16_t light2; - uint16_t temp; - uint16_t humidity; - uint16_t rssi; - uint16_t cpu; - uint16_t lpm; - uint16_t transmit; - uint16_t listen; - rimeaddr_t parent; - uint16_t parent_etx; - uint16_t parent_rtmetric; - uint16_t battery_voltage; - uint16_t battery_indicator; - uint16_t num_neighbors; -}; -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(shell_sky_alldata_process, ev, data) -{ - static unsigned long last_cpu, last_lpm, last_transmit, last_listen; - unsigned long cpu, lpm, transmit, listen; - struct sky_alldata_msg msg; - struct collect_neighbor *n; - PROCESS_BEGIN(); - - - SENSORS_ACTIVATE(light_sensor); - SENSORS_ACTIVATE(battery_sensor); - SENSORS_ACTIVATE(sht11_sensor); - - msg.len = sizeof(struct sky_alldata_msg) / sizeof(uint16_t); - msg.clock = clock_time(); -#if TIMESYNCH_CONF_ENABLED - msg.timesynch_time = timesynch_time(); -#else /* TIMESYNCH_CONF_ENABLED */ - msg.timesynch_time = 0; -#endif /* TIMESYNCH_CONF_ENABLED */ - msg.light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC); - msg.light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR); - msg.temp = sht11_sensor.value(SHT11_SENSOR_TEMP); - msg.humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY); - - energest_flush(); - - cpu = energest_type_time(ENERGEST_TYPE_CPU) - last_cpu; - lpm = energest_type_time(ENERGEST_TYPE_LPM) - last_lpm; - transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit; - listen = energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen; - - /* Make sure that the values are within 16 bits. */ - while(cpu >= 65536ul || lpm >= 65536ul || - transmit >= 65536ul || listen >= 65536ul) { - cpu /= 2; - lpm /= 2; - transmit /= 2; - listen /= 2; - } - - msg.cpu = cpu; - msg.lpm = lpm; - msg.transmit = transmit; - msg.listen = listen; - - last_cpu = energest_type_time(ENERGEST_TYPE_CPU); - last_lpm = energest_type_time(ENERGEST_TYPE_LPM); - last_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT); - last_listen = energest_type_time(ENERGEST_TYPE_LISTEN); - - rimeaddr_copy(&msg.parent, &shell_collect_conn.parent); - n = collect_neighbor_list_find(&shell_collect_conn.neighbor_list, - &shell_collect_conn.parent); - if(n != NULL) { - msg.parent_etx = collect_neighbor_link_estimate(n); - msg.parent_rtmetric = n->rtmetric; - } else { - msg.parent_etx = 0; - msg.parent_rtmetric = 0; - } - msg.battery_voltage = battery_sensor.value(0); - msg.battery_indicator = sht11_sensor.value(SHT11_SENSOR_BATTERY_INDICATOR); - msg.num_neighbors = collect_neighbor_list_num(&shell_collect_conn.neighbor_list); - shell_output(&sky_alldata_command, &msg, sizeof(msg), "", 0); - - SENSORS_DEACTIVATE(light_sensor); - SENSORS_DEACTIVATE(battery_sensor); - SENSORS_DEACTIVATE(sht11_sensor); - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ static void periodic_debug(void *ptr) { @@ -254,10 +80,7 @@ PROCESS_THREAD(sky_shell_process, ev, data) PROCESS_BEGIN(); /* ctimer_set(&c, 20 * CLOCK_SECOND, periodic_debug, &c);*/ - - /* powertrace_start(30 * CLOCK_SECOND); - powertrace_sniff(POWERTRACE_ON);*/ - + serial_shell_init(); shell_blink_init(); /* shell_file_init(); @@ -273,14 +96,14 @@ PROCESS_THREAD(sky_shell_process, ev, data) shell_rime_debug_runicast_init();*/ /* shell_rime_sniff_init();*/ shell_sky_init(); - shell_power_init(); + shell_powertrace_init(); /* shell_base64_init();*/ shell_text_init(); shell_time_init(); /* shell_checkpoint_init();*/ /* shell_sendtest_init();*/ - shell_register_command(&sky_alldata_command); + collect_view_init(); #if DEBUG_SNIFFERS rime_sniffer_add(&s);