From 533f7abac18856ec06c61547be4915e98ff43cde Mon Sep 17 00:00:00 2001 From: mmaroti Date: Wed, 7 May 2008 20:42:45 +0000 Subject: [PATCH] no message --- apps/tests/rf230/RadioCountToDiag/Makefile | 6 + .../RadioCountToDiag/RadioCountToDiagC.nc | 51 +++++ .../RadioCountToDiag/RadioCountToDiagP.nc | 185 ++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100644 apps/tests/rf230/RadioCountToDiag/Makefile create mode 100644 apps/tests/rf230/RadioCountToDiag/RadioCountToDiagC.nc create mode 100644 apps/tests/rf230/RadioCountToDiag/RadioCountToDiagP.nc diff --git a/apps/tests/rf230/RadioCountToDiag/Makefile b/apps/tests/rf230/RadioCountToDiag/Makefile new file mode 100644 index 00000000..51e3345e --- /dev/null +++ b/apps/tests/rf230/RadioCountToDiag/Makefile @@ -0,0 +1,6 @@ +COMPONENT=RadioCountToDiagC +CFLAGS += -I$(TOSDIR)/lib/diagmsg +CFLAGS += -DCC240_DEF_CHANNEL=11 +CFLAGS += -DRF230_DEF_CHANNEL=11 +CFLAGS += -DTASKLET_IS_TASK +include $(MAKERULES) diff --git a/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagC.nc b/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagC.nc new file mode 100644 index 00000000..0cbeb3db --- /dev/null +++ b/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagC.nc @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * 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 VANDERBILT UNIVERSITY 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 VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +configuration RadioCountToDiagC +{ +} + +implementation +{ + components MainC, RadioCountToDiagP, DiagMsgC; + components ActiveMessageC, SerialActiveMessageC; + components new TimerMilliC() as SendTimerC; + components new TimerMilliC() as ReportTimerC; + + RadioCountToDiagP.Boot -> MainC; + RadioCountToDiagP.DiagMsg -> DiagMsgC; + RadioCountToDiagP.SendTimer -> SendTimerC; + RadioCountToDiagP.ReportTimer -> ReportTimerC; + + RadioCountToDiagP.SerialControl -> SerialActiveMessageC; + RadioCountToDiagP.RadioControl -> ActiveMessageC; + + RadioCountToDiagP.PacketAcknowledgements -> ActiveMessageC; + RadioCountToDiagP.AMPacket -> ActiveMessageC; + RadioCountToDiagP.Packet -> ActiveMessageC; + RadioCountToDiagP.AMSend -> ActiveMessageC.AMSend[0x11]; + RadioCountToDiagP.Receive -> ActiveMessageC.Receive[0x11]; + + components ActiveMessageAddressC; + RadioCountToDiagP.ActiveMessageAddress -> ActiveMessageAddressC; +} diff --git a/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagP.nc b/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagP.nc new file mode 100644 index 00000000..ad9de621 --- /dev/null +++ b/apps/tests/rf230/RadioCountToDiag/RadioCountToDiagP.nc @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * 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 VANDERBILT UNIVERSITY 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 VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +module RadioCountToDiagP +{ + uses + { + interface Boot; + interface DiagMsg; + + interface Timer as SendTimer; + interface Timer as ReportTimer; + + interface Receive; + interface AMSend; + interface PacketAcknowledgements; + interface AMPacket; + interface Packet; + + interface SplitControl as SerialControl; + interface SplitControl as RadioControl; + + interface ActiveMessageAddress; + } +} + +#ifndef SEND_PERIOD +#define SEND_PERIOD 10 +#endif + +implementation +{ + task void radioPowerUp() + { + if( call RadioControl.start() != SUCCESS ) + post radioPowerUp(); + } + + event void RadioControl.startDone(error_t error) + { + if( error != SUCCESS ) + post radioPowerUp(); + else + { + call SendTimer.startPeriodic(SEND_PERIOD); + call ReportTimer.startPeriodic(1000); + } + } + + event void RadioControl.stopDone(error_t error) + { + } + + task void serialPowerUp() + { + if( call SerialControl.start() != SUCCESS ) + post serialPowerUp(); + } + + event void SerialControl.startDone(error_t error) + { + if( error != SUCCESS ) + post serialPowerUp(); + else + post radioPowerUp(); + } + + event void SerialControl.stopDone(error_t error) + { + } + + event void Boot.booted() + { + post serialPowerUp(); + } + + async event void ActiveMessageAddress.changed() + { + } + + uint32_t sendCount; + uint32_t sendError; + uint32_t sendDoneSuccess; + uint32_t sendDoneError; + uint32_t ackedCount; + uint32_t ackedError; + uint32_t receiveCount; + uint32_t receiveMissed; + + event void ReportTimer.fired() + { + if( call DiagMsg.record() ) + { + call DiagMsg.uint16(sendCount); + call DiagMsg.uint16(sendError); + call DiagMsg.uint16(sendDoneSuccess); + call DiagMsg.uint16(sendDoneError); + call DiagMsg.uint16(ackedCount); + call DiagMsg.uint16(ackedError); + call DiagMsg.uint16(receiveCount); + call DiagMsg.uint16(receiveMissed); + call DiagMsg.send(); + } + } + + message_t txMsg; + + typedef struct ping_t + { + uint8_t seqNo; + uint8_t stuff[27]; + } ping_t; + + event void SendTimer.fired() + { + uint16_t addr; + + call Packet.clear(&txMsg); + call PacketAcknowledgements.requestAck(&txMsg); + + addr = call ActiveMessageAddress.amAddress(); + if( addr == 2 ) + addr = 3; + else if( addr == 3 ) + addr = 2; + else + addr = AM_BROADCAST_ADDR; + + if( call AMSend.send(addr, &txMsg, sizeof(ping_t)) == SUCCESS ) + ++sendCount; + else + ++sendError; + } + + event void AMSend.sendDone(message_t* msg, error_t error) + { + if( error == SUCCESS ) + { + ping_t* ping = (ping_t*)txMsg.data; + ++(ping->seqNo); + + ++sendDoneSuccess; + + if( call PacketAcknowledgements.wasAcked(&txMsg) ) + ++ackedCount; + else + ++ackedError; + } + else + ++sendDoneError; + } + + uint8_t rxSeqNo; + + event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) + { + ping_t* ping = (ping_t*)(msg->data); + + ++receiveCount; + receiveMissed += (uint8_t)(ping->seqNo - rxSeqNo - 1); + rxSeqNo = ping->seqNo; + + return msg; + } +} -- 2.39.2