[Firebug-cvs] fireboard/beta/fireworks/apps/DataCollection Makefile,NONE,1.1 README,NONE,1.1 Surge.h
Brought to you by:
doolin
From: Karthik D. <da...@us...> - 2005-08-28 09:17:35
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9349 Added Files: Makefile README Surge.h Surge.nc SurgeCmd.h SurgeM.nc Log Message: Data Collection app for Tmote sky --- NEW FILE: SurgeM.nc --- // $Id: SurgeM.nc,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ includes Surge; includes SurgeCmd; /* * Data gather application */ module SurgeM { provides { interface StdControl; } uses { // interface ADC; interface SplitControl as HumidityControl; interface SplitControl as PressureControl; interface ADC as Humidity; interface ADC as Temperature; interface ADC as TSR; interface ADC as PAR; interface ADC as InternalTemperature; interface ADC as InternalVoltage; interface ADC as Pressure; interface ADCError as HumidityError; interface ADCError as TemperatureError; interface Calibration as PressureCalibration; interface Timer; interface Leds; interface CC2420Control; interface MacControl; interface Send; interface RouteControl; interface Random; } } implementation { enum { HUMIDITY, TEMPERATURE, TSRSENSOR, PARSENSOR, ITEMP, IVOLT, PRESSURE, SEND }; norace uint16_t humidity, temperature, tsr, par, itemp, ivolt, pressure; norace int state; enum { TIMER_GETADC_COUNT = 1, // Timer ticks for ADC TIMER_CHIRP_COUNT = 10, // Timer on/off chirp count }; bool sleeping; // application command state bool focused; bool rebroadcast_adc_packet; TOS_Msg gMsgBuffer; norace uint16_t gSensorData; // protected by gfSendBusy flag uint32_t seqno; bool initTimer; bool gfSendBusy; int timer_rate; int timer_ticks; /*********************************************************************** * Initialization ***********************************************************************/ static void initialize() { timer_rate = INITIAL_TIMER_RATE; atomic gfSendBusy = FALSE; sleeping = FALSE; seqno = 0; initTimer = TRUE; rebroadcast_adc_packet = FALSE; focused = FALSE; // Sensor initialization state = HUMIDITY; } task void SendData() { SurgeMsg *pReading; uint16_t Len; dbg(DBG_USR1, "SurgeM: Sending sensor reading\n"); if ((pReading = (SurgeMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { pReading->type = SURGE_TYPE_SENSORREADING; pReading->parentaddr = call RouteControl.getParent(); pReading->humidity = humidity; pReading->temperature = temperature; pReading->itemp = itemp; pReading->ivolt = ivolt; pReading->pressure = pressure; pReading->seq_no = seqno++; #ifdef MHOP_LEDS call Leds.redOn(); #endif if ((call Send.send(&gMsgBuffer,sizeof(SurgeMsg))) != SUCCESS) atomic gfSendBusy = FALSE; } } command result_t StdControl.init() { initialize(); call HumidityControl.init(); call PressureControl.init(); return SUCCESS; } event result_t HumidityControl.initDone() { return SUCCESS; } event result_t PressureControl.initDone() { return SUCCESS; } command result_t StdControl.start() { uint16_t randomtimer; call CC2420Control.SetRFPower(15); call MacControl.enableAck(); randomtimer = (call Random.rand() & 0xfff) + 1; call HumidityControl.start(); call PressureControl.start(); return call Timer.start(TIMER_ONE_SHOT, randomtimer); } event result_t HumidityControl.startDone() { call HumidityError.enable(); call TemperatureError.enable(); call Timer.start( TIMER_ONE_SHOT, 250 ); return SUCCESS; } event result_t PressureControl.startDone() { call Timer.start( TIMER_REPEAT, 2048 ); return SUCCESS; } command result_t StdControl.stop() { call HumidityControl.stop(); call PressureControl.stop(); return call Timer.stop(); } event result_t HumidityControl.stopDone() { call HumidityError.disable(); call TemperatureError.disable(); return SUCCESS; } event result_t PressureControl.stopDone() { return SUCCESS; } event result_t PressureCalibration.dataReady(char word, uint16_t value) { atomic pressure = value; call Temperature.getData(); return SUCCESS; } /*********************************************************************** * Commands and events ***********************************************************************/ event result_t Timer.fired() { // set a timeout in case a task post fails (rare) call Timer.start(TIMER_ONE_SHOT, 100); switch(state) { case HUMIDITY: call Humidity.getData(); break; case TEMPERATURE: call Temperature.getData(); break; case TSRSENSOR: call TSR.getData(); break; case PARSENSOR: call PAR.getData(); break; case ITEMP: call InternalTemperature.getData(); break; case IVOLT: call InternalVoltage.getData(); break; case PRESSURE: call PressureCalibration.getData(); break; case SEND: post SendData(); break; default: call Timer.start(TIMER_ONE_SHOT, 10); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { humidity = data; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { humidity = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { temperature = data; call Timer.start(TIMER_ONE_SHOT, 10); state = TSRSENSOR; return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { temperature = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = TSRSENSOR; return SUCCESS; } async event result_t TSR.dataReady(uint16_t data) { tsr = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PARSENSOR; return SUCCESS; } async event result_t PAR.dataReady(uint16_t data) { par = data; call Timer.start(TIMER_ONE_SHOT, 10); state = ITEMP; return SUCCESS; } async event result_t InternalTemperature.dataReady(uint16_t data) { itemp = data; call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } async event result_t InternalVoltage.dataReady(uint16_t data) { ivolt = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PRESSURE; return SUCCESS; } async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; call Timer.start(TIMER_ONE_SHOT, 10); state = SEND; return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { dbg(DBG_USR2, "SurgeM: output complete 0x%x\n", success); #ifdef MHOP_LEDS call Leds.redOff(); #endif atomic gfSendBusy = FALSE; return SUCCESS; } } --- NEW FILE: Makefile --- PFLAGS= -I%T/lib/MultiHopLQI -I%T/../contrib/moteiv/tos/sensorboards/pressure -DSEND_QUEUE_SIZE=8 -DMHOP_LEDS # -I%T/platform/msp430 -I%T/platform/telos PLATFORMS=telos telosa telosb tmote TINYOS_NP ?= BNP COMPONENT=Surge include ${MAKERULES} --- NEW FILE: Surge.nc --- // $Id: Surge.nc,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ /** * **/ includes Surge; includes SurgeCmd; includes MultiHop; configuration Surge { } implementation { components Main, SurgeM , TimerC , LedsC , DelugeC // , NoLeds // , DemoSensorC as Sensor , RandomLFSR , GenericComm as Comm // , Bcast , CC2420RadioC , LQIMultiHopRouter as multihopM // , QueuedSend; , HumidityC , HamamatsuC , InternalTempC , InternalVoltageC , IntersemaPressure ; Main.StdControl -> DelugeC; Main.StdControl -> TimerC; Main.StdControl -> Comm; // Main.StdControl -> Bcast.StdControl; Main.StdControl -> HamamatsuC; Main.StdControl -> InternalTempC; Main.StdControl -> InternalVoltageC; Main.StdControl -> multihopM.StdControl; // Main.StdControl -> QueuedSend.StdControl; Main.StdControl -> SurgeM.StdControl; SurgeM.Timer -> TimerC.Timer[unique("Timer")]; SurgeM.Leds -> LedsC; // NoLeds; SurgeM.Random -> RandomLFSR; // SurgeM.Bcast -> Bcast.Receive[AM_SURGECMDMSG]; // Bcast.ReceiveMsg[AM_SURGECMDMSG] -> Comm.ReceiveMsg[AM_SURGECMDMSG]; SurgeM.CC2420Control -> CC2420RadioC.CC2420Control; SurgeM.MacControl -> CC2420RadioC.MacControl; //Sensors SurgeM.HumidityControl -> HumidityC; SurgeM.Humidity -> HumidityC.Humidity; SurgeM.Temperature -> HumidityC.Temperature; SurgeM.TSR -> HamamatsuC.TSR; SurgeM.PAR -> HamamatsuC.PAR; SurgeM.InternalTemperature -> InternalTempC; SurgeM.InternalVoltage -> InternalVoltageC; SurgeM.PressureControl -> IntersemaPressure; SurgeM.Pressure -> IntersemaPressure.Pressure; SurgeM.PressureCalibration -> IntersemaPressure.Calibration; SurgeM.TemperatureError -> HumidityC.TemperatureError; SurgeM.HumidityError -> HumidityC.HumidityError; SurgeM.RouteControl -> multihopM; SurgeM.Send -> multihopM.Send[AM_SURGEMSG]; multihopM.ReceiveMsg[AM_SURGEMSG] -> Comm.ReceiveMsg[AM_SURGEMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } --- NEW FILE: SurgeCmd.h --- // $Id: SurgeCmd.h,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ typedef struct SurgeCmdMsg { uint16_t type; union { // FOR SURGE_TYPE_SETRATE uint32_t newrate; // FOR SURGE_TYPE_FOCUS uint16_t focusaddr; } args; } SurgeCmdMsg; enum { AM_SURGECMDMSG = 18 }; --- NEW FILE: README --- README for Surge Author/Contact: tin...@mi... $Revision: 1.1 $ Description: Surge is an example application that uses MultiHop ad-hoc routing. It is designed to be used in conjunction with the Surge java tool. Each Surge node takes temperature readings and forwards them to a base station. The node can also respond to broadcast commands from the base. This version of surge in contrib/ucb/SurgeTelos only supports (and has been tested on) the Telos platform. Please do not try to run this version of Surge on any other platform. Other platforms may use Surge in tinyos-1.x/apps/Surge Tools: net.tinyos.surge.MainClass This class processes sensor data from Surge programmed nodes via a GenericBase station. The java applet snoops the multihop headers to provide a graphical view of the logical network topology. It also permits variation of the sample rates and sending pre-defined commands to the surge nodes. In tinyos-1.x/tools/java/net/tinyos/surge, you must recompile the java classes based on this version of Surge: cd $TOSDIR/../tools/java/net/tinyos/surge make clean SURGE_PLATFORM=telos make This creates classes from Surge.h and SurgeCmd.h in contrib/ucb/apps/Surge and Multihop.h from contrib/ucb/tos/lib/MultiHopLQI. Now you can run Surge with java net.tinyos.surge.MainClass 0x7D Make sure SerialForwarder is connected to Telos before running the Surge java GUI. --- NEW FILE: Surge.h --- // $Id: Surge.h,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ int INITIAL_TIMER_RATE = 2048; int FOCUS_TIMER_RATE = 1000; int FOCUS_NOTME_TIMER_RATE = 1000; enum { SURGE_TYPE_SENSORREADING = 0, SURGE_TYPE_ROOTBEACON = 1, SURGE_TYPE_SETRATE = 2, SURGE_TYPE_SLEEP = 3, SURGE_TYPE_WAKEUP = 4, SURGE_TYPE_FOCUS = 5, SURGE_TYPE_UNFOCUS = 6 }; typedef struct SurgeMsg { uint16_t type; uint16_t humidity; uint16_t temperature; // uint16_t tsr; // uint16_t par; uint16_t itemp; uint16_t ivolt; uint16_t pressure; uint16_t parentaddr; uint32_t seq_no; } SurgeMsg; enum { AM_SURGEMSG = 17 }; |