[Firebug-cvs] fireboard/beta/fireworks/apps/Fireworks TODO,NONE,1.1 FireworksC.nc,1.2,1.3 FireworksM
Brought to you by:
doolin
From: Karthik D. <da...@us...> - 2005-07-25 22:08:25
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/Fireworks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16159 Modified Files: FireworksC.nc FireworksM.nc Makefile Added Files: TODO Log Message: Working version of Fireworks tinyos code Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/Fireworks/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 21 Jul 2005 03:08:27 -0000 1.1 --- Makefile 25 Jul 2005 22:08:16 -0000 1.2 *************** *** 1,15 **** - CWD = $(shell pwd) - COMPONENT=FireworksC SENSORBOARD=micasb ! PFLAGS+=-DDELUGE_LEDS ! PFLAGS +=-I$(CWD) ! PLATFORMS=mica2 ! FIREBOARDROOT=/home/kar/firebug/fireboard ! ! include $(TOSROOT)/tools/make/Makerules ! ! ! ! ! --- 1,7 ---- SENSORBOARD=micasb ! COMPONENT=FireworksC ! PFLAGS +=-DDELUGE_LEDS ! PFLAGS += -I%T/lib/Deluge -I%T/interfaces -I%T/tos/lib/Commands -I%T/platform/mica2 ! include ../Makerules ! PLATFORMS = mica2 mica2dot telos telosb telosa Index: FireworksC.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/Fireworks/FireworksC.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FireworksC.nc 21 Jul 2005 06:04:47 -0000 1.2 --- FireworksC.nc 25 Jul 2005 22:08:16 -0000 1.3 *************** *** 13,36 **** implementation { components Main ! , GenericComm, , TimerC - , ADCC - , CC1000RadioC , DelugeC , FireworksM , LedsC; - Main.StdControl -> FireworksM.StdControl; Main.StdControl -> DelugeC; ! Main.StdControl -> GenericComm.Control; ! Main.StdControl -> TimerC.Control; ! Fireworks.SendPingMsg -> GenericComm.SendMsg[AM_PINGMSG]; ! Fireworks.ReceivePingMsg -> GenericComm.ReceiveMsg[AM_PINGMSG]; ! Fireworks.SendDataMsg -> GenericComm.SendMsg[AM_DATAMSG]; ! Fireworks.ReceiveDataRequestMsg -> GenericComm.ReceiveMsg[AM_DATAREQUESTMSG]; ! Fireworks.CC1000Control -> CC1000RadioC; ! Fireworks.Leds -> LedsC; ! Fireworks.Timer -> TimerC.Timer[unique("Timer")]; } --- 13,39 ---- implementation { components Main ! , GenericComm , TimerC , DelugeC + // , ADCC + , CC1000RadioC , FireworksM , LedsC; Main.StdControl -> FireworksM.StdControl; + Main.StdControl -> GenericComm.Control; Main.StdControl -> DelugeC; ! Main.StdControl -> TimerC; ! FireworksM.CommControl -> GenericComm; ! FireworksM.SendPingMsg -> GenericComm.SendMsg[AM_PINGMSG]; ! FireworksM.ReceivePingMsg -> GenericComm.ReceiveMsg[AM_PINGMSG]; ! FireworksM.SendPingReplyMsg -> GenericComm.SendMsg[AM_PINGREPLYMSG]; ! FireworksM.ReceivePingReplyMsg -> GenericComm.ReceiveMsg[AM_PINGREPLYMSG]; ! FireworksM.SendDataMsg -> GenericComm.SendMsg[AM_DATAMSG]; ! FireworksM.ReceiveDataMsg -> GenericComm.ReceiveMsg[AM_DATAMSG]; ! FireworksM.ReceiveDataRequestMsg -> GenericComm.ReceiveMsg[AM_DATAREQUESTMSG]; ! FireworksM.CC1000Control -> CC1000RadioC; ! FireworksM.Leds -> LedsC; ! FireworksM.Timer -> TimerC.Timer[unique("Timer")]; } --- NEW FILE: TODO --- - Implement ReceiveDataMsg.receive - Write README.txt Index: FireworksM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/Fireworks/FireworksM.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FireworksM.nc 21 Jul 2005 06:04:47 -0000 1.2 --- FireworksM.nc 25 Jul 2005 22:08:16 -0000 1.3 *************** *** 7,19 **** */ ! module FireworksM { ! provides interface StdControl; ! uses interface SendMsg as SendPingMsg; ! uses interface SendMsg as SendDataMsg; ! uses interface ReceiveMsg as ReceiveDataRequestMsg; ! uses Timer; ! uses CC1000Control; ! uses interface Leds; } --- 7,29 ---- */ ! includes Fireworks; ! module FireworksM { ! provides { ! interface StdControl; ! } ! uses { ! interface StdControl as CommControl; ! interface SendMsg as SendPingMsg; ! interface SendMsg as SendDataMsg; ! interface SendMsg as SendPingReplyMsg; ! interface ReceiveMsg as ReceiveDataRequestMsg; ! interface ReceiveMsg as ReceiveDataMsg; ! interface ReceiveMsg as ReceivePingMsg; ! interface ReceiveMsg as ReceivePingReplyMsg; ! interface Timer; ! interface Leds; ! interface CC1000Control; ! } } *************** *** 25,28 **** --- 35,39 ---- uint16_t tFrequency; uint16_t seqno; + uint16_t src; uint8_t sendBusy; uint8_t taskBusy; *************** *** 44,48 **** call Leds.redOff(); } ! if(seq&0x2) { call Leds.greenOn(); --- 55,59 ---- call Leds.redOff(); } ! if(seq&0x2) { call Leds.greenOn(); *************** *** 51,57 **** call Leds.greenOff(); } ! if(seq&0x4) { ! call Leds.yellowOn(); } else { --- 62,68 ---- call Leds.greenOff(); } ! if(seq&0x4) { ! call Leds.yellowOn(); } else { *************** *** 59,73 **** } } ! command result_t StdControl.init() { ! atomic { } ! return SUCCESS; } ! command result_t StdControl.start() { blink(CLEAR); ! seqno = 1; sendBusy = FALSE; --- 70,169 ---- } } + + void clearPacket() { + uint8_t i; + for(i=0; i< 29; i++) + msg.data[i]=0x0; + } + + task void sendPing() { + /* NOTE: Again, since tasks dont seem to allow parameters, + we use the global 'dest' as destination */ + clearPacket(); + pMsg = (PingMsg *) &(msg.data); + pMsg->source = TOS_LOCAL_ADDRESS; + pMsg->seqno = seqno++; + + if(!sendBusy) { + sendBusy = TRUE; + if(!call SendPingMsg.send(dest, sizeof(PingMsg), &msg)) { + sendBusy = FALSE; + blink(ERROR); + return; + } + else { + /* We have sent the msg. Set timer to fire after 3 seconds */ + blink(SND_P_MSG); + call Timer.start(TIMER_ONE_SHOT, 3072); + counter++; + return; + } + } + } + + task void sendPingReply() { + /* NOTE: Since tasks do not seem to allow parameters, we use + src and seqno as global variables. They should not be + used by anybody else */ ! prMsg = (PingReplyMsg *) &(msg.data); ! ! prMsg->source = src; ! prMsg->seqno = seqno; ! ! if(!sendBusy) { ! sendBusy = TRUE; ! if(!call SendPingReplyMsg.send(src, sizeof(PingReplyMsg), &msg)) { ! sendBusy = FALSE; ! blink(ERROR); ! return; ! } ! else { ! blink(SND_PR_MSG); ! } } ! return; ! } ! ! task void sendData() { ! } ! ! ! task void takeMeasurements() { ! uint16_t trial; ! /* The way we take measurements is that we ping the intended ! node and he replies (if he receives the packet) with the ! RSSI value. Once we send a ping, we start a timer. If the ! timer expires, we assume that the node is out of range/unreachable */ ! dest = 1; ! for(dest=1; dest <= nNodes; dest++) { ! counter = 0; ! taskBusy = FALSE; ! sendBusy = FALSE; ! if(dest != TOS_LOCAL_ADDRESS) { ! trial = 1; ! while(trial <= nTrials) { ! if(!taskBusy) { ! trial ++; ! taskBusy = TRUE; ! post sendPing(); ! } ! } ! } ! } ! ! post sendData(); ! } ! ! command result_t StdControl.init() { ! call Leds.init(); ! call CommControl.init(); ! return SUCCESS; } ! command result_t StdControl.start() { blink(CLEAR); ! seqno = 1; sendBusy = FALSE; *************** *** 75,84 **** counter = 0; dest = 0; ! // return call Clock.setRate(TOS_I16PS, TOSS16PS); return SUCCESS; } ! command result_t StdControl.stop() { call Timer.stop(); return SUCCESS; } --- 171,184 ---- counter = 0; dest = 0; ! ! call CommControl.start(); ! return SUCCESS; } ! command result_t StdControl.stop() { + call CommControl.stop(); call Timer.stop(); + return SUCCESS; } *************** *** 87,91 **** prMsg = (PingReplyMsg *) &(m->data); ! if(TOS_LOCAL_ADDRESS == prMsg->source && seqno == prMsg->seqno) { data[dest][counter] = prMsg->RSSI; --- 187,191 ---- prMsg = (PingReplyMsg *) &(m->data); ! if(TOS_LOCAL_ADDRESS == prMsg->source && seqno == prMsg->seqno) { data[dest][counter] = prMsg->RSSI; *************** *** 94,101 **** } ! ! return SUCCESS; } ! event TOS_MsgPtr ReceiveDataRequestMsg.receive(TOS_MsgPtr m) { drMsg = (DataRequestMsg *) (&(m->data)); --- 194,201 ---- } ! ! return m; } ! event TOS_MsgPtr ReceiveDataRequestMsg.receive(TOS_MsgPtr m) { drMsg = (DataRequestMsg *) (&(m->data)); *************** *** 111,222 **** post takeMeasurements(); } } ! ! event result_t ReceivePingMsg.receive(TOS_MsgPtr m) { ! uint16_t source; ! if(TOS_LOCAL_ADDRESS == m->addr) { blink(RCV_P_MSG); pMsg = (PingMsg *) &(m->data); ! while(taskBusy); ! taskBusy = TRUE; ! post sendPingReply(pMsg->source, pMsg->seqno); } ! return SUCCESS; } ! ! task void sendPingReply(uint16_t src, uint16_t sq) { ! prMsg = (PingReplyMsg *) &(msg.data); ! ! prMsg->source = src; ! prMsg->seqno = sq; ! ! if(!sendBusy) { ! sendBusy = TRUE; ! if(!call SendPingReply.send(src, &msg)) { ! sendBusy = FALSE; ! blink(ERROR); ! return; ! } ! else { ! blink(SND_PR_MSG); ! } ! } ! return; } ! ! task void takeMeasurements() { ! uint16_t trial; ! /* The way we take measurements is that we ping the intended ! node and he replies (if he receives the packet) with the ! RSSI value. Once we send a ping, we start a timer. If the ! timer expires, we assume that the node is out of range/unreachable */ ! dest = 1; ! for(dest=1; dest <= nNodes; dest++) { ! counter = 0; ! taskBusy = FALSE; ! sendBusy = FALSE; ! if(dest != TOS_LOCAL_ADDRESS) { ! trial = 1; ! while(trial <= nTrials) { ! if(!taskBusy) { ! trial ++; ! taskBusy = TRUE; ! post task sendPingMsg(dest); ! } ! } ! } ! } ! ! post sendData(); } - - task void sendPingMsg(uint16_t d) { - pMsg = (PingMsg *) &(msg.data); - pMsg->source = TOS_LOCAL_ADDRESS; - pMsg->seqno = seqno++; - - if(!sendBusy) { - sendBusy = TRUE; - if(!call SendPingMsg.send(d, sizeof(PingMsg), pMsg)) { - sendBusy = FALSE; - blink(ERROR); - return; - } - else { - /* We have sent the msg. Set timer to fire after 3 seconds */ - blink(SND_P_MSG); - Timer.start(TIMER_ONE_SHOT, 3072); - counter++; - return; - } - } - - event result_t Timer.fired() { - /* This means that we have to time out, redo state and declare - this packet to have been lost */ - data[dest][counter]=LOST; - taskBusy = FALSE; - sendBusy = FALSE; - return SUCCESS; - } - - event result_t_MsgPtr SendPingMsg.sendDone(TOSMsg_Ptr m) { - sendBusy = FALSE; - return SUCCESS; - } ! event result_t_MsgPtr SendPingReplyMsg.sendDone(TOSMsg_Ptr m) { ! sendBusy = FALSE; ! return SUCCESS; ! } ! ! event result_t_MsgPtr SendDataMsg.sendDone(TOSMsg_Ptr m) { ! sendBusy = FALSE; ! return SUCCESS; ! } } --- 211,259 ---- post takeMeasurements(); } + + return m; } ! ! event TOS_MsgPtr ReceiveDataMsg.receive(TOS_MsgPtr m) { ! return m; ! } ! ! event TOS_MsgPtr ReceivePingMsg.receive(TOS_MsgPtr m) { if(TOS_LOCAL_ADDRESS == m->addr) { blink(RCV_P_MSG); pMsg = (PingMsg *) &(m->data); ! while(taskBusy); ! taskBusy = TRUE; ! post sendPingReply(); } ! ! return m; ! } ! ! event result_t Timer.fired() { ! /* This means that we have to time out, redo state and declare ! this packet to have been lost */ ! data[dest][counter]=LOST; ! taskBusy = FALSE; ! sendBusy = FALSE; return SUCCESS; } ! ! event result_t SendPingMsg.sendDone(TOS_MsgPtr m, result_t s) { ! sendBusy = FALSE; ! return SUCCESS; } ! ! event result_t SendPingReplyMsg.sendDone(TOS_MsgPtr m, result_t s) { ! sendBusy = FALSE; ! return SUCCESS; } ! event result_t SendDataMsg.sendDone(TOS_MsgPtr m, result_t s) { ! sendBusy = FALSE; ! return SUCCESS; ! } } |