[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestAMOnOff Makefile,
NONE, 1.1.4.2 README, NONE, 1.1.4.2 TestAMOnOffAppC.nc, NONE,
1.1.4.2 TestAMOnOffC.nc, NONE, 1.1.4.2
Kevin Klues
klueska at users.sourceforge.net
Mon May 15 11:35:25 PDT 2006
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tests/TestAM Makefile, NONE,
1.1.4.2 TestAMAppC.nc, NONE, 1.1.4.2 TestAMC.nc, NONE, 1.1.4.2
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestAMService
Makefile, NONE, 1.1.4.2 TestAMServiceAppC.nc, NONE,
1.1.4.2 TestAMServiceC.nc, NONE, 1.1.4.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestAMOnOff
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv18756/apps/tests/TestAMOnOff
Added Files:
Tag: tos-2-resource-pm-eval-cand
Makefile README TestAMOnOffAppC.nc TestAMOnOffC.nc
Log Message:
Merging the development branch with the resource/power management evaluation branch. After this merge all files except those already commited should be identical.
--- NEW FILE: Makefile ---
COMPONENT=TestAMOnOffAppC
PFLAGS += -I%T/lib/oski -DSERVICE_SLAVE
include $(MAKERULES)
--- NEW FILE: README ---
TestAMOnOff
This application has two different versions, slave and master. The
version compiled is determined by a compile-time flag of either
-DSERVICE_MASTER
or
-DSERVICE_SLAVE
in the Makefile. A master is always on. A master broadcasts a packet
every second. Four of the five packets are data packets; every fifth
packet is a control packet. It toggles Led0 when it sends a data
packet and Led1 when it sends a control packet.
When a slave hears a data packet, it toggles Led0. When a slave
hears a control packet, it turns off its radio for a short
period of time. Led1 indicates whether the slave's radio is on.
If you install a slave and a master, you should see the slave blink
Led0 a few times, then when the master blinks Led1, the slave stops
for a little while, then resumes blinking Led0.
Philip Levis, 8/7/2005
--- NEW FILE: TestAMOnOffAppC.nc ---
// $Id: TestAMOnOffAppC.nc,v 1.1.4.2 2006/05/15 18:35:23 klueska Exp $
/* tab:4
* "Copyright (c) 2000-2005 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-2005 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.
*/
/**
* This OSKI test application tests whether OSKI can turn the active
* message service on and off. It has two versions: slave and master,
* which are set by a command line -D: SERVICE_SLAVE or
* SERVICE_MASTER. A master is always on, and transmits data packets
* at 1Hz. Every 5s, it transmits a power message. When a slave hears
* a data message, it toggles its red led; when it hears a power
* message, it turns off its radio, which it turns back on in a few
* seconds. This essentially tests whether ActiveMessageC is turning
* the radio off appropriately. It uses AM types 240 (power messages)
* and 241 (data messages).
*
* @author Philip Levis
* @date June 19 2005
*/
configuration TestAMOnOffAppC {}
implementation {
components MainC, TestAMOnOffC as App, LedsC;
components new AMSenderC(240) as PowerSend;
components new AMReceiverC(240) as PowerReceive;
components new AMSenderC(241) as DataSend;
components new AMReceiverC(241) as DataReceive;
components new TimerMilliC();
components ActiveMessageC;
App.Boot -> MainC.Boot;
App.PowerReceive -> PowerReceive;
App.PowerSend -> PowerSend;
App.DataReceive -> DataReceive;
App.DataSend -> DataSend;
App.RadioControl -> ActiveMessageC;
App.Leds -> LedsC;
App.MilliTimer -> TimerMilliC;
}
--- NEW FILE: TestAMOnOffC.nc ---
// $Id: TestAMOnOffC.nc,v 1.1.4.2 2006/05/15 18:35:23 klueska Exp $
/* tab:4
* "Copyright (c) 2000-2005 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.
*/
/**
* Implementation of the OSKI TestAMOnOff application. This
* application has two versions: slave and master. A master is always
* on, and transmits data packets at 1Hz. Every 5s, it transmits a
* power message. When a slave hears a data message, it toggles its
* red led; when it hears a power message, it turns off its radio,
* which it turns back on in a few seconds. This essentially tests
* whether ActiveMessageC is turning the radio off appropriately.
*
* @author Philip Levis
* @date June 19 2005
*
**/
#include "Timer.h"
module TestAMOnOffC {
uses {
interface Leds;
interface Boot;
interface Receive as PowerReceive;
interface AMSend as PowerSend;
interface Receive as DataReceive;
interface AMSend as DataSend;
interface Timer<TMilli> as MilliTimer;
interface SplitControl as RadioControl;
}
}
implementation {
message_t packet;
bool locked;
uint8_t counter = 0;
bool on = FALSE;
event void Boot.booted() {
call RadioControl.start();
call MilliTimer.startPeriodic(1000);
}
event void MilliTimer.fired() {
call Leds.led2Toggle();
counter++;
#ifdef SERVICE_SLAVE
if ((counter % 7) == 0) {
if (!on) {
call RadioControl.start();
}
}
#endif
#ifdef SERVICE_MASTER
if (locked) {
return;
}
if (counter % 5) {
if (call DataSend.send(AM_BROADCAST_ADDR, &packet, 0) == SUCCESS) {
call Leds.led0Toggle();
locked = TRUE;
}
}
else {
if (call PowerSend.send(AM_BROADCAST_ADDR, &packet, 0) == SUCCESS) {
call Leds.led1Toggle();
locked = TRUE;
}
}
#endif
}
event message_t* DataReceive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
#ifdef SERVICE_SLAVE
call Leds.led0Toggle();
#endif
return bufPtr;
}
event message_t* PowerReceive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
#ifdef SERVICE_SLAVE
if (on) {
call RadioControl.stop();
}
#endif
return bufPtr;
}
event void PowerSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
}
event void DataSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
}
event void RadioControl.startDone(error_t err) {
if (err != SUCCESS) {
call RadioControl.start();
}
else {
on = TRUE;
#ifdef SERVICE_SLAVE
call Leds.led1On();
#endif
}
}
event void RadioControl.stopDone(error_t err) {
if (err != SUCCESS) {
call RadioControl.stop();
}
else {
on = FALSE;
#ifdef SERVICE_SLAVE
call Leds.led1Off();
#endif
}
}
}
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tests/TestAM Makefile, NONE,
1.1.4.2 TestAMAppC.nc, NONE, 1.1.4.2 TestAMC.nc, NONE, 1.1.4.2
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestAMService
Makefile, NONE, 1.1.4.2 TestAMServiceAppC.nc, NONE,
1.1.4.2 TestAMServiceC.nc, NONE, 1.1.4.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list