[Firebug-cvs] fireboard/beta/fireworks/apps/DataCollection Calibration.h,1.1,1.2 DataCollection.h,1.
Brought to you by:
doolin
From: Karthik D. <da...@us...> - 2005-08-29 00:26:01
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17281 Modified Files: Calibration.h DataCollection.h DataCollection.nc DataCollectionM.nc Makefile Log Message: Functional tos modules Index: DataCollectionM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollectionM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollectionM.nc 28 Aug 2005 20:03:47 -0000 1.1 --- DataCollectionM.nc 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 42,46 **** enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION, HUMIDITY, TEMPERATURE, --- 42,46 ---- enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION=1, HUMIDITY, TEMPERATURE, *************** *** 50,54 **** IVOLT, PRESSURE, ! SEND }; --- 50,55 ---- IVOLT, PRESSURE, ! SEND, ! SENDCALIBRATION }; *************** *** 66,75 **** 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; --- 67,76 ---- bool rebroadcast_adc_packet; ! TOS_Msg dataBuffer; ! TOS_Msg calibrationBuffer; uint32_t seqno; bool initTimer; ! bool sendBusy; ! uint8_t sending; // sending=1 => data; sending=2 => calibration int timer_rate; *************** *** 81,85 **** static void initialize() { timer_rate = INITIAL_TIMER_RATE; ! atomic gfSendBusy = FALSE; sleeping = FALSE; seqno = 0; --- 82,86 ---- static void initialize() { timer_rate = INITIAL_TIMER_RATE; ! atomic sendBusy = FALSE; sleeping = FALSE; seqno = 0; *************** *** 87,103 **** rebroadcast_adc_packet = FALSE; focused = FALSE; // Sensor initialization state = PRESSURECALIBRATION; } task void SendData() { DataCollectionMsg *pReading; - CalibrationMsg *cReading; uint16_t Len; - uint8_t i; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); ! if ((pReading = (DataCollectionMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; --- 88,113 ---- rebroadcast_adc_packet = FALSE; focused = FALSE; + sending = 1; // Sensor initialization state = PRESSURECALIBRATION; + call Leds.set(PRESSURECALIBRATION); + } + + void clearPacket() { + uint8_t i; + for(i=0; i< 29; i++) { + dataBuffer.data[i]=0x0; + calibrationBuffer.data[i]=0x0; + } } task void SendData() { DataCollectionMsg *pReading; uint16_t Len; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); ! clearPacket(); ! if ((pReading = (DataCollectionMsg *)call Send.getBuffer(&dataBuffer,&Len)) != NULL) { pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; *************** *** 110,134 **** pReading->seq_no = seqno; ! #ifdef MHOP_LEDS ! call Leds.redOn(); ! #endif ! if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) ! atomic gfSendBusy = FALSE; } - if ((cReading = (CalibrationMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { - cReading->type = CALIBRATION; - cReading->src = TOS_LOCAL_ADDRESS; - cReading->parentaddr = call RouteControl.getParent(); - for(i=0;i<=4;i++) - cReading->calibration[i]=cal[i]; - cReading->seq_no = seqno++; - - #ifdef MHOP_LEDS - call Leds.redOn(); - #endif - if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) - atomic gfSendBusy = FALSE; - } } --- 120,128 ---- pReading->seq_no = seqno; ! sendBusy = TRUE; ! if ((call Send.send(&dataBuffer,sizeof(DataCollectionMsg))) != SUCCESS) ! atomic sendBusy = FALSE; } } *************** *** 149,157 **** command result_t StdControl.start() { call CC2420Control.SetRFPower(15); call MacControl.enableAck(); - call HumidityControl.start(); - call PressureControl.start(); return SUCCESS; } --- 143,151 ---- command result_t StdControl.start() { + call HumidityControl.start(); + call PressureControl.start(); call CC2420Control.SetRFPower(15); call MacControl.enableAck(); return SUCCESS; } *************** *** 187,199 **** } - event result_t PressureCalibration.dataReady(char word, uint16_t value) { - atomic cal[word-1] = value; - if(word >= 4) { - state = HUMIDITY; - } - - return SUCCESS; - } - /*********************************************************************** * Commands and events --- 181,184 ---- *************** *** 201,209 **** 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 PRESSURECALIBRATION: call PressureCalibration.getData(); case HUMIDITY: call Humidity.getData(); --- 186,193 ---- event result_t Timer.fired() { switch(state) { case PRESSURECALIBRATION: call PressureCalibration.getData(); + break; case HUMIDITY: call Humidity.getData(); *************** *** 235,268 **** break; default: ! call Timer.start(TIMER_ONE_SHOT, 10000); } 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 = HUMIDITY; return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { ! temperature = data; ! call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { ! temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } --- 219,267 ---- break; default: ! // call Timer.start(TIMER_ONE_SHOT, 10000); } return SUCCESS; } + event result_t PressureCalibration.dataReady(char word, uint16_t value) { + atomic cal[word-1] = value; + if(word >= 4) { + state = HUMIDITY; + call Leds.set(HUMIDITY); + call Timer.start(TIMER_ONE_SHOT, 100); + } + + return SUCCESS; + } + async event result_t Humidity.dataReady(uint16_t data) { ! atomic humidity = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; + call Leds.set(TEMPERATURE); return SUCCESS; } event result_t HumidityError.error(uint8_t token) { ! atomic humidity = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = HUMIDITY; + call Leds.set(HUMIDITY); return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { ! atomic temperature = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = IVOLT; + call Leds.set(IVOLT); return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { ! atomic temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; + call Leds.set(TEMPERATURE); return SUCCESS; } *************** *** 292,298 **** async event result_t InternalVoltage.dataReady(uint16_t data) { ! ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, 10); state = PRESSURE; return SUCCESS; } --- 291,298 ---- async event result_t InternalVoltage.dataReady(uint16_t data) { ! atomic ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = PRESSURE; + call Leds.set(PRESSURE); return SUCCESS; } *************** *** 300,319 **** 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, "DataCollectionM: output complete 0x%x\n", success); - #ifdef MHOP_LEDS - call Leds.redOff(); - #endif - atomic gfSendBusy = FALSE; - return SUCCESS; - } } --- 300,342 ---- async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; ! call Timer.start(TIMER_ONE_SHOT, 100); state = SEND; ! call Leds.set(SEND); ! return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { + CalibrationMsg *cReading; + uint8_t i; + uint16_t Len; + atomic sendBusy = FALSE; + dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); + if(sending == 1) { + sending = 2; + if ((cReading = (CalibrationMsg *)call Send.getBuffer(&calibrationBuffer,&Len)) != NULL) { + cReading->type = CALIBRATION; + cReading->src = TOS_LOCAL_ADDRESS; + cReading->parentaddr = call RouteControl.getParent(); + for(i=0;i<=4;i++) + cReading->calibration[i]=cal[i]; + cReading->seq_no = seqno++; + + call Leds.set(SENDCALIBRATION); + atomic sendBusy = TRUE; + if ((call Send.send(&calibrationBuffer,sizeof(CalibrationMsg))) != SUCCESS) + atomic sendBusy = FALSE; + } + } + else if(sending == 2) { + state = PRESSURECALIBRATION; + sending = 1; + // call Leds.set(PRESSURECALIBRATION); + call Timer.start(TIMER_ONE_SHOT, 1000); + return SUCCESS; + } + } } Index: Calibration.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/Calibration.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Calibration.h 28 Aug 2005 20:03:47 -0000 1.1 --- Calibration.h 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 1,12 **** typedef struct CalibrationMsg { - uint16_t type; uint16_t src; ! uint16_t parentaddr; uint16_t calibration[4]; ! uint16_t seq_no; } CalibrationMsg; enum { ! AM_CALIBRATIONMSG = 18 }; --- 1,12 ---- typedef struct CalibrationMsg { uint16_t src; ! uint16_t type; uint16_t calibration[4]; ! uint16_t parentaddr; ! uint32_t seq_no; } CalibrationMsg; enum { ! AM_CALIBRATIONMSG = 42 }; Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 28 Aug 2005 20:03:47 -0000 1.2 --- Makefile 29 Aug 2005 00:25:53 -0000 1.3 *************** *** 1,3 **** ! 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 --- 1,3 ---- ! PFLAGS= -I%T/lib/MultiHopLQI -I%T/../contrib/moteiv/tos/sensorboards/pressure -DSEND_QUEUE_SIZE=8 -DDC_LEDS # -I%T/platform/msp430 -I%T/platform/telos PLATFORMS=telos telosa telosb tmote Index: DataCollection.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollection.nc 28 Aug 2005 20:04:23 -0000 1.1 --- DataCollection.nc 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 8,12 **** --- 8,16 ---- components Main, DataCollectionM , TimerC + #ifdef DC_LEDS , LedsC + #else + , NoLeds as LedsC + #endif , DelugeC // , NoLeds *************** *** 67,72 **** DataCollectionM.Send -> multihopM.Send[AM_DATACOLLECTIONMSG]; multihopM.ReceiveMsg[AM_DATACOLLECTIONMSG] -> Comm.ReceiveMsg[AM_DATACOLLECTIONMSG]; ! DataCollectionM.Send -> multihopM.Send[AM_CALIBRATIONMSG]; ! multihopM.ReceiveMsg[AM_CALIBRATIONMSG] -> Comm.ReceiveMsg[AM_CALIBRATIONMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } --- 71,76 ---- DataCollectionM.Send -> multihopM.Send[AM_DATACOLLECTIONMSG]; multihopM.ReceiveMsg[AM_DATACOLLECTIONMSG] -> Comm.ReceiveMsg[AM_DATACOLLECTIONMSG]; ! // DataCollectionM.CalibrationSend -> multihopM.Send[AM_CALIBRATIONMSG]; ! // multihopM.ReceiveMsg[AM_CALIBRATIONMSG] -> Comm.ReceiveMsg[AM_CALIBRATIONMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } Index: DataCollection.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollection.h 28 Aug 2005 20:03:47 -0000 1.1 --- DataCollection.h 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 8,12 **** enum { SENSORREADING = 0, ! CALIBRATION }; --- 8,12 ---- enum { SENSORREADING = 0, ! CALIBRATION = 1 }; *************** *** 27,31 **** enum { ! AM_DATACOLLECTIONMSG = 17 }; --- 27,31 ---- enum { ! AM_DATACOLLECTIONMSG = 42 }; |